@@ -228,7 +228,7 @@ ShareDbMongo.prototype._writeSnapshot = function(collectionName, id, snapshot, o
228
228
if ( err ) return callback ( err ) ;
229
229
var doc = castToDoc ( id , snapshot , opLink ) ;
230
230
if ( doc . _v === 1 ) {
231
- collection . insertOne ( doc , function ( err , result ) {
231
+ collection . insertOne ( doc , function ( err ) {
232
232
if ( err ) {
233
233
// Return non-success instead of duplicate key error, since this is
234
234
// expected to occur during simultaneous creates on the same id
@@ -277,7 +277,6 @@ ShareDbMongo.prototype.getSnapshotBulk = function(collectionName, ids, fields, o
277
277
var snapshot = castToSnapshot ( docs [ i ] ) ;
278
278
snapshotMap [ snapshot . id ] = snapshot ;
279
279
}
280
- var uncreated = [ ] ;
281
280
for ( var i = 0 ; i < ids . length ; i ++ ) {
282
281
var id = ids [ i ] ;
283
282
if ( snapshotMap [ id ] ) continue ;
@@ -538,7 +537,7 @@ function getLatestDeleteOp(ops) {
538
537
}
539
538
540
539
function getLinkedOps ( ops , to , link ) {
541
- var linkedOps = [ ]
540
+ var linkedOps = [ ] ;
542
541
for ( var i = ops . length ; i -- && link ; ) {
543
542
var op = ops [ i ] ;
544
543
if ( link . equals ? ! link . equals ( op . _id ) : link !== op . _id ) continue ;
@@ -556,7 +555,7 @@ function getOpsQuery(id, from, to) {
556
555
from = from == null ? 0 : from ;
557
556
var query = {
558
557
d : id ,
559
- v : { $gte : from }
558
+ v : { $gte : from }
560
559
} ;
561
560
562
561
if ( to != null ) {
@@ -624,7 +623,7 @@ ShareDbMongo.prototype._getOpLink = function(collectionName, id, to, callback) {
624
623
if ( ! this . getOpsWithoutStrictLinking ) return this . _getSnapshotOpLink ( collectionName , id , callback ) ;
625
624
626
625
var db = this ;
627
- this . getOpCollection ( collectionName , function ( error , collection ) {
626
+ this . getOpCollection ( collectionName , function ( error , collection ) {
628
627
if ( error ) return callback ( error ) ;
629
628
630
629
// If to is null, we want the most recent version, so just return the
@@ -635,7 +634,7 @@ ShareDbMongo.prototype._getOpLink = function(collectionName, id, to, callback) {
635
634
636
635
var query = {
637
636
d : id ,
638
- v : { $gte : to }
637
+ v : { $gte : to }
639
638
} ;
640
639
641
640
var projection = {
@@ -644,11 +643,11 @@ ShareDbMongo.prototype._getOpLink = function(collectionName, id, to, callback) {
644
643
o : 1
645
644
} ;
646
645
647
- var cursor = collection . find ( query ) . sort ( { v : 1 } ) . project ( projection ) ;
646
+ var cursor = collection . find ( query ) . sort ( { v : 1 } ) . project ( projection ) ;
648
647
649
- getFirstOpWithUniqueVersion ( cursor , null , function ( error , op ) {
648
+ getFirstOpWithUniqueVersion ( cursor , null , function ( error , op ) {
650
649
if ( error ) return callback ( error ) ;
651
- if ( op ) return callback ( null , { _o : op . o , _v : op . v } ) ;
650
+ if ( op ) return callback ( null , { _o : op . o , _v : op . v } ) ;
652
651
653
652
// If we couldn't find an op to link back from, then fall back to using the current
654
653
// snapshot, which is guaranteed to have a link to a valid op.
@@ -674,7 +673,7 @@ function getFirstOpWithUniqueVersion(cursor, opLinkValidator, callback) {
674
673
return closeCursor ( cursor , callback , error , opWithUniqueVersion ) ;
675
674
}
676
675
677
- cursor . next ( function ( error , op ) {
676
+ cursor . next ( function ( error , op ) {
678
677
if ( error ) {
679
678
return closeCursor ( cursor , callback , error ) ;
680
679
}
@@ -685,7 +684,7 @@ function getFirstOpWithUniqueVersion(cursor, opLinkValidator, callback) {
685
684
}
686
685
687
686
function closeCursor ( cursor , callback , error , returnValue ) {
688
- cursor . close ( function ( closeError ) {
687
+ cursor . close ( function ( closeError ) {
689
688
error = error || closeError ;
690
689
callback ( error , returnValue ) ;
691
690
} ) ;
@@ -1086,7 +1085,7 @@ function parseQuery(inputQuery) {
1086
1085
var cursorOperationValue = null ;
1087
1086
1088
1087
if ( inputQuery . $query ) {
1089
- throw new Error ( " unexpected $query: should have called checkQuery" ) ;
1088
+ throw new Error ( ' unexpected $query: should have called checkQuery' ) ;
1090
1089
} else {
1091
1090
for ( var key in inputQuery ) {
1092
1091
if ( collectionOperationsMap [ key ] ) {
@@ -1276,8 +1275,8 @@ function castToDoc(id, snapshot, opLink) {
1276
1275
var data = snapshot . data ;
1277
1276
var doc =
1278
1277
( isObject ( data ) ) ? shallowClone ( data ) :
1279
- ( data === undefined ) ? { } :
1280
- { _data : data } ;
1278
+ ( data === undefined ) ? { } :
1279
+ { _data : data } ;
1281
1280
doc . _id = id ;
1282
1281
doc . _type = snapshot . type ;
1283
1282
doc . _v = snapshot . v ;
@@ -1361,10 +1360,10 @@ function getProjection(fields, options) {
1361
1360
}
1362
1361
1363
1362
var collectionOperationsMap = {
1364
- ' $distinct' : function ( collection , query , value , cb ) {
1363
+ $distinct : function ( collection , query , value , cb ) {
1365
1364
collection . distinct ( value . field , query , cb ) ;
1366
1365
} ,
1367
- ' $aggregate' : function ( collection , query , value , cb ) {
1366
+ $aggregate : function ( collection , query , value , cb ) {
1368
1367
collection . aggregate ( value , function ( err , resultsOrCursor ) {
1369
1368
if ( err ) {
1370
1369
return cb ( err ) ;
@@ -1384,7 +1383,7 @@ var collectionOperationsMap = {
1384
1383
}
1385
1384
} ) ;
1386
1385
} ,
1387
- ' $mapReduce' : function ( collection , query , value , cb ) {
1386
+ $mapReduce : function ( collection , query , value , cb ) {
1388
1387
if ( typeof value !== 'object' ) {
1389
1388
var err = ShareDbMongo . malformedQueryOperatorError ( '$mapReduce' ) ;
1390
1389
return cb ( err ) ;
@@ -1400,61 +1399,79 @@ var collectionOperationsMap = {
1400
1399
} ;
1401
1400
1402
1401
var cursorOperationsMap = {
1403
- ' $count' : function ( cursor , value , cb ) {
1402
+ $count : function ( cursor , value , cb ) {
1404
1403
cursor . count ( cb ) ;
1405
1404
} ,
1406
- ' $explain' : function ( cursor , verbosity , cb ) {
1405
+ $explain : function ( cursor , verbosity , cb ) {
1407
1406
cursor . explain ( verbosity , cb ) ;
1408
1407
} ,
1409
- ' $map' : function ( cursor , fn , cb ) {
1408
+ $map : function ( cursor , fn , cb ) {
1410
1409
cursor . map ( fn , cb ) ;
1411
1410
}
1412
1411
} ;
1413
1412
1414
1413
var cursorTransformsMap = {
1415
- '$batchSize' : function ( cursor , size ) { return cursor . batchSize ( size ) ; } ,
1416
- '$comment' : function ( cursor , text ) { return cursor . comment ( text ) ; } ,
1417
- '$hint' : function ( cursor , index ) { return cursor . hint ( index ) ; } ,
1418
- '$max' : function ( cursor , value ) { return cursor . max ( value ) ; } ,
1419
- '$maxScan' : function ( cursor , value ) { return cursor . maxScan ( value ) ; } ,
1420
- '$maxTimeMS' : function ( cursor , milliseconds ) {
1414
+ $batchSize : function ( cursor , size ) {
1415
+ return cursor . batchSize ( size ) ;
1416
+ } ,
1417
+ $comment : function ( cursor , text ) {
1418
+ return cursor . comment ( text ) ;
1419
+ } ,
1420
+ $hint : function ( cursor , index ) {
1421
+ return cursor . hint ( index ) ;
1422
+ } ,
1423
+ $max : function ( cursor , value ) {
1424
+ return cursor . max ( value ) ;
1425
+ } ,
1426
+ $maxScan : function ( cursor , value ) {
1427
+ return cursor . maxScan ( value ) ;
1428
+ } ,
1429
+ $maxTimeMS : function ( cursor , milliseconds ) {
1421
1430
return cursor . maxTimeMS ( milliseconds ) ;
1422
1431
} ,
1423
- '$min' : function ( cursor , value ) { return cursor . min ( value ) ; } ,
1424
- '$noCursorTimeout' : function ( cursor ) {
1432
+ $min : function ( cursor , value ) {
1433
+ return cursor . min ( value ) ;
1434
+ } ,
1435
+ $noCursorTimeout : function ( cursor ) {
1425
1436
// no argument to cursor method
1426
1437
return cursor . noCursorTimeout ( ) ;
1427
1438
} ,
1428
- ' $orderby' : function ( cursor , value ) {
1439
+ $orderby : function ( cursor , value ) {
1429
1440
console . warn ( 'Deprecated: $orderby; Use $sort.' ) ;
1430
1441
return cursor . sort ( value ) ;
1431
1442
} ,
1432
- ' $readConcern' : function ( cursor , level ) {
1443
+ $readConcern : function ( cursor , level ) {
1433
1444
return cursor . readConcern ( level ) ;
1434
1445
} ,
1435
- ' $readPref' : function ( cursor , value ) {
1446
+ $readPref : function ( cursor , value ) {
1436
1447
// The Mongo driver cursor method takes two argments. Our queries
1437
1448
// have a single value for the '$readPref' property. Interpret as
1438
1449
// an object with {mode, tagSet}.
1439
1450
if ( typeof value !== 'object' ) return null ;
1440
1451
return cursor . readPref ( value . mode , value . tagSet ) ;
1441
1452
} ,
1442
- ' $returnKey' : function ( cursor ) {
1453
+ $returnKey : function ( cursor ) {
1443
1454
// no argument to cursor method
1444
1455
return cursor . returnKey ( ) ;
1445
1456
} ,
1446
- ' $snapshot' : function ( cursor ) {
1457
+ $snapshot : function ( cursor ) {
1447
1458
// no argument to cursor method
1448
1459
return cursor . snapshot ( ) ;
1449
1460
} ,
1450
- '$sort' : function ( cursor , value ) { return cursor . sort ( value ) ; } ,
1451
- '$skip' : function ( cursor , value ) { return cursor . skip ( value ) ; } ,
1452
- '$limit' : function ( cursor , value ) { return cursor . limit ( value ) ; } ,
1453
- '$showDiskLoc' : function ( cursor , value ) {
1461
+ $sort : function ( cursor , value ) {
1462
+ return cursor . sort ( value ) ;
1463
+ } ,
1464
+ $skip : function ( cursor , value ) {
1465
+ return cursor . skip ( value ) ;
1466
+ } ,
1467
+ $limit : function ( cursor , value ) {
1468
+ return cursor . limit ( value ) ;
1469
+ } ,
1470
+ $showDiskLoc : function ( cursor , value ) {
1454
1471
console . warn ( 'Deprecated: $showDiskLoc; Use $showRecordId.' ) ;
1455
1472
return cursor . showRecordId ( value ) ;
1456
1473
} ,
1457
- ' $showRecordId' : function ( cursor ) {
1474
+ $showRecordId : function ( cursor ) {
1458
1475
// no argument to cursor method
1459
1476
return cursor . showRecordId ( ) ;
1460
1477
}
@@ -1483,7 +1500,7 @@ ShareDbMongo.$queryDeprecatedError = function() {
1483
1500
return { code : 4106 , message : '$query property deprecated in queries' } ;
1484
1501
} ;
1485
1502
ShareDbMongo . malformedQueryOperatorError = function ( operator ) {
1486
- return { code : 4107 , message : " Malformed query operator: " + operator } ;
1503
+ return { code : 4107 , message : ' Malformed query operator: ' + operator } ;
1487
1504
} ;
1488
1505
ShareDbMongo . onlyOneCollectionOperationError = function ( operation1 , operation2 ) {
1489
1506
return {
0 commit comments