@@ -40,7 +40,7 @@ function ObjectID(id) {
40
40
// hex string. For LoopBack, we only allow 24-byte hex string, but 12-byte
41
41
// string such as 'line-by-line' should be kept as string
42
42
if ( ObjectIdValueRegex . test ( id ) ) {
43
- return bson . ObjectID ( id ) ;
43
+ return new bson . ObjectID ( id ) ;
44
44
} else {
45
45
return id ;
46
46
}
@@ -310,15 +310,15 @@ MongoDB.prototype.connect = function(callback) {
310
310
g . error (
311
311
'{{MongoDB}} connection is failed: %s %s' ,
312
312
self . settings . url ,
313
- err
313
+ err ,
314
314
) ;
315
315
}
316
316
if ( callback ) callback ( err ) ;
317
317
}
318
318
319
319
new mongodb . MongoClient ( self . settings . url , validOptions ) . connect ( function (
320
320
err ,
321
- client
321
+ client ,
322
322
) {
323
323
if ( err ) {
324
324
onError ( err ) ;
@@ -336,7 +336,7 @@ MongoDB.prototype.connect = function(callback) {
336
336
}
337
337
self . db = client . db (
338
338
url . dbName || self . settings . database ,
339
- url . db_options || self . settings
339
+ url . db_options || self . settings ,
340
340
) ;
341
341
if ( callback ) callback ( err , self . db ) ;
342
342
} ) ;
@@ -486,7 +486,7 @@ MongoDB.prototype.execute = function(modelName, command) {
486
486
'Connection not established - MongoDB: model=%s command=%s -- error=%s' ,
487
487
modelName ,
488
488
command ,
489
- err
489
+ err ,
490
490
) ;
491
491
}
492
492
doExecute ( ) ;
@@ -532,7 +532,7 @@ MongoDB.prototype.execute = function(modelName, command) {
532
532
debug ( 'MongoDB: model=%s command=%s' , modelName , command , args ) ;
533
533
return collection [ command ] . apply ( collection , args ) ;
534
534
} ,
535
- callback
535
+ callback ,
536
536
) ;
537
537
}
538
538
} ;
@@ -797,7 +797,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate(
797
797
modelName ,
798
798
data ,
799
799
options ,
800
- callback
800
+ callback ,
801
801
) {
802
802
const self = this ;
803
803
if ( self . debug ) {
@@ -852,7 +852,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate(
852
852
if ( callback ) {
853
853
callback ( err , self . fromDatabase ( modelName , object ) , info ) ;
854
854
}
855
- }
855
+ } ,
856
856
) ;
857
857
} ;
858
858
@@ -1112,7 +1112,7 @@ function convertToMeters(distance, unit) {
1112
1112
console . warn (
1113
1113
'unsupported unit ' +
1114
1114
unit +
1115
- ", fallback to mongodb default unit 'meters'"
1115
+ ", fallback to mongodb default unit 'meters'" ,
1116
1116
) ;
1117
1117
return distance ;
1118
1118
}
@@ -1390,7 +1390,7 @@ MongoDB.prototype.all = function all(modelName, filter, options, callback) {
1390
1390
objs ,
1391
1391
filter . include ,
1392
1392
options ,
1393
- callback
1393
+ callback ,
1394
1394
) ;
1395
1395
} else {
1396
1396
callback ( null , objs ) ;
@@ -1409,7 +1409,7 @@ MongoDB.prototype.destroyAll = function destroyAll(
1409
1409
modelName ,
1410
1410
where ,
1411
1411
options ,
1412
- callback
1412
+ callback ,
1413
1413
) {
1414
1414
const self = this ;
1415
1415
if ( self . debug ) {
@@ -1473,7 +1473,7 @@ MongoDB.prototype.replaceById = function replace(modelName, id, data, options, c
1473
1473
const oid = this . coerceId ( modelName , id , options ) ;
1474
1474
this . replaceWithOptions ( modelName , oid , data , { upsert : false } , function (
1475
1475
err ,
1476
- data
1476
+ data ,
1477
1477
) {
1478
1478
cb ( err , data ) ;
1479
1479
} ) ;
@@ -1501,7 +1501,7 @@ MongoDB.prototype.replaceWithOptions = function(modelName, id, data, options, cb
1501
1501
data = self . toDatabase ( modelName , data ) ;
1502
1502
this . execute ( modelName , 'replaceOne' , { _id : id } , data , options , function (
1503
1503
err ,
1504
- info
1504
+ info ,
1505
1505
) {
1506
1506
debug ( 'updateWithOptions.callback' , modelName , { _id : id } , data , err , info ) ;
1507
1507
if ( err ) return cb && cb ( err ) ;
@@ -1542,7 +1542,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs(
1542
1542
id ,
1543
1543
data ,
1544
1544
options ,
1545
- cb
1545
+ cb ,
1546
1546
) {
1547
1547
const self = this ;
1548
1548
@@ -1593,7 +1593,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs(
1593
1593
if ( cb ) {
1594
1594
cb ( err , object ) ;
1595
1595
}
1596
- }
1596
+ } ,
1597
1597
) ;
1598
1598
} ;
1599
1599
@@ -1616,7 +1616,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll(
1616
1616
where ,
1617
1617
data ,
1618
1618
options ,
1619
- cb
1619
+ cb ,
1620
1620
) {
1621
1621
const self = this ;
1622
1622
if ( self . debug ) {
@@ -1650,7 +1650,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll(
1650
1650
if ( cb ) {
1651
1651
cb ( err , { count : affectedCount } ) ;
1652
1652
}
1653
- }
1653
+ } ,
1654
1654
) ;
1655
1655
} ;
1656
1656
@@ -1801,13 +1801,13 @@ MongoDB.prototype.autoupdate = function(models, cb) {
1801
1801
. createIndex (
1802
1802
index . fields || index . keys ,
1803
1803
index . options ,
1804
- indexCallback
1804
+ indexCallback ,
1805
1805
) ;
1806
1806
} ,
1807
- modelCallback
1807
+ modelCallback ,
1808
1808
) ;
1809
1809
} ,
1810
- cb
1810
+ cb ,
1811
1811
) ;
1812
1812
} else {
1813
1813
self . dataSource . once ( 'connected' , function ( ) {
@@ -1854,7 +1854,7 @@ MongoDB.prototype.automigrate = function(models, cb) {
1854
1854
'Error dropping collection %s for model %s: ' ,
1855
1855
collectionName ,
1856
1856
modelName ,
1857
- err
1857
+ err ,
1858
1858
) ;
1859
1859
if (
1860
1860
! (
@@ -1879,7 +1879,7 @@ MongoDB.prototype.automigrate = function(models, cb) {
1879
1879
return cb && cb ( err ) ;
1880
1880
}
1881
1881
self . autoupdate ( models , cb ) ;
1882
- }
1882
+ } ,
1883
1883
) ;
1884
1884
} else {
1885
1885
self . dataSource . once ( 'connected' , function ( ) {
@@ -2064,14 +2064,14 @@ function optimizedFindOrCreate(modelName, filter, data, options, callback) {
2064
2064
if ( filter && filter . include ) {
2065
2065
self . _models [ modelName ] . model . include ( [ value ] , filter . include , function (
2066
2066
err ,
2067
- data
2067
+ data ,
2068
2068
) {
2069
2069
callback ( err , data [ 0 ] , created ) ;
2070
2070
} ) ;
2071
2071
} else {
2072
2072
callback ( null , value , created ) ;
2073
2073
}
2074
- }
2074
+ } ,
2075
2075
) ;
2076
2076
}
2077
2077
0 commit comments