@@ -27,13 +27,11 @@ const CommandCursor = require('./command_cursor');
27
27
// Operations
28
28
const checkForAtomicOperators = require ( './operations/collection_ops' ) . checkForAtomicOperators ;
29
29
const ensureIndex = require ( './operations/collection_ops' ) . ensureIndex ;
30
- const findAndModify = require ( './operations/collection_ops' ) . findAndModify ;
31
- const findAndRemove = require ( './operations/collection_ops' ) . findAndRemove ;
32
30
const group = require ( './operations/collection_ops' ) . group ;
33
31
const parallelCollectionScan = require ( './operations/collection_ops' ) . parallelCollectionScan ;
34
- const removeDocuments = require ( './operations/collection_ops ' ) . removeDocuments ;
32
+ const removeDocuments = require ( './operations/common_functions ' ) . removeDocuments ;
35
33
const save = require ( './operations/collection_ops' ) . save ;
36
- const updateDocuments = require ( './operations/collection_ops ' ) . updateDocuments ;
34
+ const updateDocuments = require ( './operations/common_functions ' ) . updateDocuments ;
37
35
38
36
const AggregateOperation = require ( './operations/aggregate' ) ;
39
37
const BulkWriteOperation = require ( './operations/bulk_write' ) ;
@@ -48,6 +46,7 @@ const DropIndexOperation = require('./operations/drop_index');
48
46
const DropIndexesOperation = require ( './operations/drop_indexes' ) ;
49
47
const EstimatedDocumentCountOperation = require ( './operations/estimated_document_count' ) ;
50
48
const FindOneOperation = require ( './operations/find_one' ) ;
49
+ const FindAndModifyOperation = require ( './operations/find_and_modify' ) ;
51
50
const FindOneAndDeleteOperation = require ( './operations/find_one_and_delete' ) ;
52
51
const FindOneAndReplaceOperation = require ( './operations/find_one_and_replace' ) ;
53
52
const FindOneAndUpdateOperation = require ( './operations/find_one_and_update' ) ;
@@ -1665,14 +1664,11 @@ function _findAndModify(query, sort, doc, options, callback) {
1665
1664
// Force read preference primary
1666
1665
options . readPreference = ReadPreference . PRIMARY ;
1667
1666
1668
- return executeLegacyOperation ( this . s . topology , findAndModify , [
1669
- this ,
1670
- query ,
1671
- sort ,
1672
- doc ,
1673
- options ,
1667
+ return executeOperation (
1668
+ this . s . topology ,
1669
+ new FindAndModifyOperation ( this , query , sort , doc , options ) ,
1674
1670
callback
1675
- ] ) ;
1671
+ ) ;
1676
1672
}
1677
1673
1678
1674
/**
@@ -1695,13 +1691,14 @@ Collection.prototype.findAndRemove = deprecate(function(query, sort, options, ca
1695
1691
sort = args . length ? args . shift ( ) || [ ] : [ ] ;
1696
1692
options = args . length ? args . shift ( ) || { } : { } ;
1697
1693
1698
- return executeLegacyOperation ( this . s . topology , findAndRemove , [
1699
- this ,
1700
- query ,
1701
- sort ,
1702
- options ,
1694
+ // Add the remove option
1695
+ options . remove = true ;
1696
+
1697
+ return executeOperation (
1698
+ this . s . topology ,
1699
+ new FindAndModifyOperation ( this , query , sort , null , options ) ,
1703
1700
callback
1704
- ] ) ;
1701
+ ) ;
1705
1702
} , 'collection.findAndRemove is deprecated. Use findOneAndDelete instead.' ) ;
1706
1703
1707
1704
/**
0 commit comments