mongodb 3.6.3 → 3.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/HISTORY.md +27 -1
  2. package/README.md +1 -3
  3. package/lib/admin.js +10 -8
  4. package/lib/aggregation_cursor.js +7 -1
  5. package/lib/bulk/common.js +5 -4
  6. package/lib/collection.js +111 -65
  7. package/lib/core/cursor.js +4 -1
  8. package/lib/core/sdam/monitor.js +14 -11
  9. package/lib/core/sdam/topology.js +2 -1
  10. package/lib/core/topologies/mongos.js +2 -1
  11. package/lib/core/topologies/replset.js +13 -7
  12. package/lib/core/topologies/server.js +3 -2
  13. package/lib/core/uri_parser.js +18 -2
  14. package/lib/core/wireprotocol/query.js +12 -11
  15. package/lib/core/wireprotocol/write_command.js +10 -1
  16. package/lib/cursor.js +15 -13
  17. package/lib/db.js +43 -27
  18. package/lib/explain.js +55 -0
  19. package/lib/gridfs/grid_store.js +13 -9
  20. package/lib/gridfs-stream/upload.js +5 -3
  21. package/lib/mongo_client.js +10 -8
  22. package/lib/operations/aggregate.js +5 -7
  23. package/lib/operations/command_v2.js +10 -1
  24. package/lib/operations/common_functions.js +14 -27
  25. package/lib/operations/connect.js +30 -7
  26. package/lib/operations/delete_many.js +15 -2
  27. package/lib/operations/delete_one.js +15 -2
  28. package/lib/operations/distinct.js +10 -2
  29. package/lib/operations/find.js +7 -1
  30. package/lib/operations/find_and_modify.js +14 -1
  31. package/lib/operations/find_one.js +4 -0
  32. package/lib/operations/map_reduce.js +20 -1
  33. package/lib/operations/operation.js +11 -1
  34. package/lib/operations/update_many.js +23 -2
  35. package/lib/operations/update_one.js +22 -16
  36. package/lib/url_parser.js +19 -14
  37. package/lib/utils.js +22 -2
  38. package/lib/write_concern.js +18 -4
  39. package/package.json +3 -2
package/HISTORY.md CHANGED
@@ -1,7 +1,33 @@
1
- # Change Log
1
+ # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.6.4](https://github.com/mongodb/node-mongodb-native/compare/v3.6.3...v3.6.4) (2021-02-02)
6
+
7
+
8
+ ### Features
9
+
10
+ * add explain support ([#2626](https://github.com/mongodb/node-mongodb-native/issues/2626)) ([a827807](https://github.com/mongodb/node-mongodb-native/commit/a8278070992d2de4134dc0841b4027a6cc745a93))
11
+ * Deprecate top-level write concern option keys ([#2624](https://github.com/mongodb/node-mongodb-native/issues/2624)) ([0516d93](https://github.com/mongodb/node-mongodb-native/commit/0516d93f74de4b58a99e8455e59678d4b09cd4a7))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * Allow GridFS write stream to destroy ([#2702](https://github.com/mongodb/node-mongodb-native/issues/2702)) ([b5e9d67](https://github.com/mongodb/node-mongodb-native/commit/b5e9d67d5cd9b1912a349789cf2a122e00a46d1b))
17
+ * awaitable isMaster timeout must respect connectTimeoutMS ([#2627](https://github.com/mongodb/node-mongodb-native/issues/2627)) ([b365c50](https://github.com/mongodb/node-mongodb-native/commit/b365c5061ded832e1682167edac58e8a04b05fc4))
18
+ * don't add empty query string items to connection string ([8897259](https://github.com/mongodb/node-mongodb-native/commit/889725980ec1e3b4be4a74170bea0a3e3d23cf13))
19
+ * don't reset monitor if we aren't streaming topology changes ([a10171b](https://github.com/mongodb/node-mongodb-native/commit/a10171b57d2414f6df2aa8ffe9c2d3938ad838d1))
20
+ * dont parse tls/ssl file paths in uri ([#2718](https://github.com/mongodb/node-mongodb-native/issues/2718)) ([f89e4c1](https://github.com/mongodb/node-mongodb-native/commit/f89e4c1bd59c64664e8c9aa218bcb856be325d34))
21
+ * hasAtomicOperator check respects toBSON transformation ([#2696](https://github.com/mongodb/node-mongodb-native/issues/2696)) ([60936dc](https://github.com/mongodb/node-mongodb-native/commit/60936dca74167de239d1bb51a23cc9870860bdc4))
22
+ * honor ignoreUndefined on findAndModify commands ([#2671](https://github.com/mongodb/node-mongodb-native/issues/2671)) ([a25b67c](https://github.com/mongodb/node-mongodb-native/commit/a25b67c6ac13b6347cb78c4fc56613f3daf44300))
23
+ * ignore ENOTFOUND during TXT record lookup ([2036fe7](https://github.com/mongodb/node-mongodb-native/commit/2036fe7b298b9678e29ede87c1035c748ff89fcd))
24
+ * respect readPreference and writeConcern from connection string ([#2711](https://github.com/mongodb/node-mongodb-native/issues/2711)) ([b657c8c](https://github.com/mongodb/node-mongodb-native/commit/b657c8c4f3f86018cc4824f84cb22e1527d9f9af))
25
+ * restore auto direct connection behavior ([#2719](https://github.com/mongodb/node-mongodb-native/issues/2719)) ([617d9de](https://github.com/mongodb/node-mongodb-native/commit/617d9dec5180c5f7b67bd8c944c168d4cbd27e1c))
26
+ * support empty TXT records in legacy url parser ([2fa5c5f](https://github.com/mongodb/node-mongodb-native/commit/2fa5c5f2a113920baa8e67a1c0d65432690d37fc))
27
+ * transition topology state before async calls ([#2637](https://github.com/mongodb/node-mongodb-native/issues/2637)) ([9df093c](https://github.com/mongodb/node-mongodb-native/commit/9df093c1d46e1f8616c7a979324923205ac3dcd2))
28
+ * **cursor:** don't use other operation's session for cloned cursor operation ([#2705](https://github.com/mongodb/node-mongodb-native/issues/2705)) ([8082c89](https://github.com/mongodb/node-mongodb-native/commit/8082c89f8ef3624d22f4bdd6066b6f72c44f763d))
29
+ * **find:** correctly translate timeout option into noCursorTimeout ([#2700](https://github.com/mongodb/node-mongodb-native/issues/2700)) ([e257e6b](https://github.com/mongodb/node-mongodb-native/commit/e257e6b19d810920bafc579e725e09bd0607b74b))
30
+
5
31
  <a name="3.6.3"></a>
6
32
  ## [3.6.3](https://github.com/mongodb/node-mongodb-native/compare/v3.6.1...v3.6.3) (2020-11-06)
7
33
 
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  [![npm](https://nodei.co/npm/mongodb.png?downloads=true&downloadRank=true)](https://nodei.co/npm/mongodb/) [![npm](https://nodei.co/npm-dl/mongodb.png?months=6&height=3)](https://nodei.co/npm/mongodb/)
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/mongodb/node-mongodb-native.svg?branch=2.1)](http://travis-ci.org/mongodb/node-mongodb-native)
4
- [![Coverage Status](https://coveralls.io/repos/github/mongodb/node-mongodb-native/badge.svg?branch=2.1)](https://coveralls.io/github/mongodb/node-mongodb-native?branch=2.1)
5
3
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mongodb/node-mongodb-native?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6
4
 
7
5
  # Description
@@ -15,7 +13,7 @@ The official [MongoDB](https://www.mongodb.com/) driver for Node.js. Provides a
15
13
  | what | where |
16
14
  |---------------|------------------------------------------------|
17
15
  | documentation | http://mongodb.github.io/node-mongodb-native |
18
- | api-doc | http://mongodb.github.io/node-mongodb-native/3.1/api |
16
+ | api-doc | http://mongodb.github.io/node-mongodb-native/3.6/api |
19
17
  | source | https://github.com/mongodb/node-mongodb-native |
20
18
  | mongodb | http://www.mongodb.org |
21
19
 
package/lib/admin.js CHANGED
@@ -166,10 +166,11 @@ Admin.prototype.ping = function(options, callback) {
166
166
  * @param {string} username The username.
167
167
  * @param {string} password The password.
168
168
  * @param {object} [options] Optional settings.
169
- * @param {(number|string)} [options.w] The write concern.
170
- * @param {number} [options.wtimeout] The write concern timeout.
171
- * @param {boolean} [options.j=false] Specify a journal write concern.
172
- * @param {boolean} [options.fsync=false] Specify a file sync write concern.
169
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
170
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
171
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
172
+ * @param {boolean} [options.fsync=false] **Deprecated** Specify a file sync write concern. Use writeConcern instead.
173
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
173
174
  * @param {object} [options.customData] Custom data associated with the user (only Mongodb 2.6 or higher)
174
175
  * @param {object[]} [options.roles] Roles associated with the created user (only Mongodb 2.6 or higher)
175
176
  * @param {ClientSession} [options.session] optional session to use for this operation
@@ -203,10 +204,11 @@ Admin.prototype.addUser = function(username, password, options, callback) {
203
204
  * @method
204
205
  * @param {string} username The username.
205
206
  * @param {object} [options] Optional settings.
206
- * @param {(number|string)} [options.w] The write concern.
207
- * @param {number} [options.wtimeout] The write concern timeout.
208
- * @param {boolean} [options.j=false] Specify a journal write concern.
209
- * @param {boolean} [options.fsync=false] Specify a file sync write concern.
207
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
208
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
209
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
210
+ * @param {boolean} [options.fsync=false] **Deprecated** Specify a file sync write concern. Use writeConcern instead.
211
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
210
212
  * @param {ClientSession} [options.session] optional session to use for this operation
211
213
  * @param {Admin~resultCallback} [callback] The command result callback
212
214
  * @return {Promise} returns Promise if no callback passed
@@ -202,7 +202,7 @@ class AggregationCursor extends Cursor {
202
202
  /**
203
203
  * Add a unwind stage to the aggregation pipeline
204
204
  * @method
205
- * @param {number} field The unwind field name.
205
+ * @param {(string|object)} field The unwind field name or stage document.
206
206
  * @return {AggregationCursor}
207
207
  */
208
208
  unwind(field) {
@@ -322,7 +322,13 @@ AggregationCursor.prototype.get = AggregationCursor.prototype.toArray;
322
322
 
323
323
  /**
324
324
  * Execute the explain for the cursor
325
+ *
326
+ * For backwards compatibility, a verbosity of true is interpreted as "allPlansExecution"
327
+ * and false as "queryPlanner". Prior to server version 3.6, aggregate()
328
+ * ignores the verbosity parameter and executes in "queryPlanner".
329
+ *
325
330
  * @method AggregationCursor.prototype.explain
331
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [verbosity=true] - An optional mode in which to run the explain.
326
332
  * @param {AggregationCursor~resultCallback} [callback] The result callback.
327
333
  * @return {Promise} returns Promise if no callback passed
328
334
  */
@@ -1125,10 +1125,11 @@ class BulkOperationBase {
1125
1125
  * @method
1126
1126
  * @param {WriteConcern} [_writeConcern] Optional write concern. Can also be specified through options.
1127
1127
  * @param {object} [options] Optional settings.
1128
- * @param {(number|string)} [options.w] The write concern.
1129
- * @param {number} [options.wtimeout] The write concern timeout.
1130
- * @param {boolean} [options.j=false] Specify a journal write concern.
1131
- * @param {boolean} [options.fsync=false] Specify a file sync write concern.
1128
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1129
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1130
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1131
+ * @param {boolean} [options.fsync=false] **Deprecated** Specify a file sync write concern. Use writeConcern instead.
1132
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1132
1133
  * @param {BulkOperationBase~resultCallback} [callback] A callback that will be invoked when bulkWrite finishes/errors
1133
1134
  * @throws {MongoError} Throws error if the bulk object has already been executed
1134
1135
  * @throws {MongoError} Throws error if the bulk object does not have any operations
package/lib/collection.js CHANGED
@@ -287,7 +287,6 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot', 'oplogReplay']
287
287
  * @param {object} [options.fields] **Deprecated** Use `options.projection` instead
288
288
  * @param {number} [options.skip=0] Set to skip N documents ahead in your query (useful for pagination).
289
289
  * @param {Object} [options.hint] Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1}
290
- * @param {boolean} [options.explain=false] Explain the query instead of returning the data.
291
290
  * @param {boolean} [options.snapshot=false] DEPRECATED: Snapshot query.
292
291
  * @param {boolean} [options.timeout=false] Specify if the cursor can timeout.
293
292
  * @param {boolean} [options.tailable=false] Specify if the cursor is tailable.
@@ -310,6 +309,7 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot', 'oplogReplay']
310
309
  * @param {boolean} [options.noCursorTimeout] The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
311
310
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
312
311
  * @param {boolean} [options.allowDiskUse] Enables writing to temporary files on the server.
312
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
313
313
  * @param {ClientSession} [options.session] optional session to use for this operation
314
314
  * @throws {MongoError}
315
315
  * @return {Cursor}
@@ -429,7 +429,7 @@ Collection.prototype.find = deprecateOptions(
429
429
  }
430
430
 
431
431
  // Translate to new command option noCursorTimeout
432
- if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = newOptions.timeout;
432
+ if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = !newOptions.timeout;
433
433
 
434
434
  decorateCommand(findCommand, newOptions, ['session', 'collation']);
435
435
 
@@ -492,9 +492,10 @@ Collection.prototype.find = deprecateOptions(
492
492
  * @param {object} [options] Optional settings.
493
493
  * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher.
494
494
  * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
495
- * @param {(number|string)} [options.w] The write concern.
496
- * @param {number} [options.wtimeout] The write concern timeout.
497
- * @param {boolean} [options.j=false] Specify a journal write concern.
495
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
496
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
497
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
498
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
498
499
  * @param {boolean} [options.checkKeys=true] If true, will throw if bson documents start with `$` or include a `.` in any key value
499
500
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
500
501
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
@@ -528,9 +529,10 @@ Collection.prototype.insertOne = function(doc, options, callback) {
528
529
  * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher.
529
530
  * @param {boolean} [options.ordered=true] If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails.
530
531
  * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
531
- * @param {(number|string)} [options.w] The write concern.
532
- * @param {number} [options.wtimeout] The write concern timeout.
533
- * @param {boolean} [options.j=false] Specify a journal write concern.
532
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
533
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
534
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
535
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
534
536
  * @param {boolean} [options.checkKeys=true] If true, will throw if bson documents start with `$` or include a `.` in any key value
535
537
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
536
538
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
@@ -595,9 +597,10 @@ Collection.prototype.insertMany = function(docs, options, callback) {
595
597
  * @param {boolean} [options.ordered=true] Execute write operation in ordered or unordered fashion.
596
598
  * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher.
597
599
  * @param {object[]} [options.arrayFilters] Determines which array elements to modify for update operation in MongoDB 3.6 or higher.
598
- * @param {(number|string)} [options.w] The write concern.
599
- * @param {number} [options.wtimeout] The write concern timeout.
600
- * @param {boolean} [options.j=false] Specify a journal write concern.
600
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
601
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
602
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
603
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
601
604
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
602
605
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
603
606
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
@@ -676,9 +679,10 @@ Collection.prototype.bulkWrite = function(operations, options, callback) {
676
679
  * @method
677
680
  * @param {(object|object[])} docs Documents to insert.
678
681
  * @param {object} [options] Optional settings.
679
- * @param {(number|string)} [options.w] The write concern.
680
- * @param {number} [options.wtimeout] The write concern timeout.
681
- * @param {boolean} [options.j=false] Specify a journal write concern.
682
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
683
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
684
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
685
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
682
686
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
683
687
  * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
684
688
  * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher.
@@ -733,12 +737,14 @@ Collection.prototype.insert = deprecate(function(docs, options, callback) {
733
737
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
734
738
  * @param {object} [options.hint] An optional hint for query optimization. See the {@link https://docs.mongodb.com/manual/reference/command/update/#update-command-hint|update command} reference for more information.
735
739
  * @param {boolean} [options.upsert=false] When true, creates a new document if no document matches the query..
736
- * @param {(number|string)} [options.w] The write concern.
737
- * @param {number} [options.wtimeout] The write concern timeout.
738
- * @param {boolean} [options.j=false] Specify a journal write concern.
740
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
741
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
742
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
743
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
739
744
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
740
745
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
741
746
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
747
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
742
748
  * @param {ClientSession} [options.session] optional session to use for this operation
743
749
  * @param {Collection~updateWriteOpCallback} [callback] The command result callback
744
750
  * @return {Promise} returns Promise if no callback passed
@@ -770,9 +776,10 @@ Collection.prototype.updateOne = function(filter, update, options, callback) {
770
776
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
771
777
  * @param {object} [options.hint] An optional hint for query optimization. See the {@link https://docs.mongodb.com/manual/reference/command/update/#update-command-hint|update command} reference for more information.
772
778
  * @param {boolean} [options.upsert=false] When true, creates a new document if no document matches the query.
773
- * @param {(number|string)} [options.w] The write concern.
774
- * @param {number} [options.wtimeout] The write concern timeout.
775
- * @param {boolean} [options.j=false] Specify a journal write concern.
779
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
780
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
781
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
782
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
776
783
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
777
784
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
778
785
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
@@ -808,12 +815,14 @@ Collection.prototype.replaceOne = function(filter, doc, options, callback) {
808
815
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
809
816
  * @param {object} [options.hint] An optional hint for query optimization. See the {@link https://docs.mongodb.com/manual/reference/command/update/#update-command-hint|update command} reference for more information.
810
817
  * @param {boolean} [options.upsert=false] When true, creates a new document if no document matches the query..
811
- * @param {(number|string)} [options.w] The write concern.
812
- * @param {number} [options.wtimeout] The write concern timeout.
813
- * @param {boolean} [options.j=false] Specify a journal write concern.
818
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
819
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
820
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
821
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
814
822
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
815
823
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
816
824
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
825
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
817
826
  * @param {ClientSession} [options.session] optional session to use for this operation
818
827
  * @param {Collection~updateWriteOpCallback} [callback] The command result callback
819
828
  * @return {Promise<Collection~updateWriteOpResult>} returns Promise if no callback passed
@@ -841,9 +850,10 @@ Collection.prototype.updateMany = function(filter, update, options, callback) {
841
850
  * @param {object} selector The selector for the update operation.
842
851
  * @param {object} update The update operations to be applied to the documents
843
852
  * @param {object} [options] Optional settings.
844
- * @param {(number|string)} [options.w] The write concern.
845
- * @param {number} [options.wtimeout] The write concern timeout.
846
- * @param {boolean} [options.j=false] Specify a journal write concern.
853
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
854
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
855
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
856
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
847
857
  * @param {boolean} [options.upsert=false] Update operation is an upsert.
848
858
  * @param {boolean} [options.multi=false] Update one/all documents with operation.
849
859
  * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher.
@@ -897,12 +907,14 @@ Collection.prototype.update = deprecate(function(selector, update, options, call
897
907
  * @param {object} filter The Filter used to select the document to remove
898
908
  * @param {object} [options] Optional settings.
899
909
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
900
- * @param {(number|string)} [options.w] The write concern.
901
- * @param {number} [options.wtimeout] The write concern timeout.
902
- * @param {boolean} [options.j=false] Specify a journal write concern.
910
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
911
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
912
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
913
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
903
914
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
904
915
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
905
916
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
917
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
906
918
  * @param {ClientSession} [options.session] optional session to use for this operation
907
919
  * @param {string|object} [options.hint] optional index hint for optimizing the filter query
908
920
  * @param {Collection~deleteWriteOpCallback} [callback] The command result callback
@@ -931,12 +943,14 @@ Collection.prototype.removeOne = Collection.prototype.deleteOne;
931
943
  * @param {object} filter The Filter used to select the documents to remove
932
944
  * @param {object} [options] Optional settings.
933
945
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
934
- * @param {(number|string)} [options.w] The write concern.
935
- * @param {number} [options.wtimeout] The write concern timeout.
936
- * @param {boolean} [options.j=false] Specify a journal write concern.
946
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
947
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
948
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
949
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
937
950
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
938
951
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
939
952
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
953
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
940
954
  * @param {ClientSession} [options.session] optional session to use for this operation
941
955
  * @param {string|object} [options.hint] optional index hint for optimizing the filter query
942
956
  * @param {Collection~deleteWriteOpCallback} [callback] The command result callback
@@ -965,9 +979,10 @@ Collection.prototype.removeMany = Collection.prototype.deleteMany;
965
979
  * @param {object} selector The selector for the update operation.
966
980
  * @param {object} [options] Optional settings.
967
981
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
968
- * @param {(number|string)} [options.w] The write concern.
969
- * @param {number} [options.wtimeout] The write concern timeout.
970
- * @param {boolean} [options.j=false] Specify a journal write concern.
982
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
983
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
984
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
985
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
971
986
  * @param {boolean} [options.single=false] Removes the first document found.
972
987
  * @param {ClientSession} [options.session] optional session to use for this operation
973
988
  * @param {Collection~writeOpCallback} [callback] The command result callback
@@ -998,9 +1013,10 @@ Collection.prototype.remove = deprecate(function(selector, options, callback) {
998
1013
  * @method
999
1014
  * @param {object} doc Document to save
1000
1015
  * @param {object} [options] Optional settings.
1001
- * @param {(number|string)} [options.w] The write concern.
1002
- * @param {number} [options.wtimeout] The write concern timeout.
1003
- * @param {boolean} [options.j=false] Specify a journal write concern.
1016
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1017
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1018
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1019
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1004
1020
  * @param {ClientSession} [options.session] optional session to use for this operation
1005
1021
  * @param {Collection~writeOpCallback} [callback] The command result callback
1006
1022
  * @return {Promise} returns Promise if no callback passed
@@ -1044,7 +1060,6 @@ Collection.prototype.save = deprecate(function(doc, options, callback) {
1044
1060
  * @param {object} [options.fields] **Deprecated** Use `options.projection` instead
1045
1061
  * @param {number} [options.skip=0] Set to skip N documents ahead in your query (useful for pagination).
1046
1062
  * @param {Object} [options.hint] Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1}
1047
- * @param {boolean} [options.explain=false] Explain the query instead of returning the data.
1048
1063
  * @param {boolean} [options.snapshot=false] DEPRECATED: Snapshot query.
1049
1064
  * @param {boolean} [options.timeout=false] Specify if the cursor can timeout.
1050
1065
  * @param {boolean} [options.tailable=false] Specify if the cursor is tailable.
@@ -1063,6 +1078,7 @@ Collection.prototype.save = deprecate(function(doc, options, callback) {
1063
1078
  * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system
1064
1079
  * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1065
1080
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
1081
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
1066
1082
  * @param {ClientSession} [options.session] optional session to use for this operation
1067
1083
  * @param {Collection~resultCallback} [callback] The command result callback
1068
1084
  * @return {Promise} returns Promise if no callback passed
@@ -1122,10 +1138,10 @@ Collection.prototype.rename = function(newName, options, callback) {
1122
1138
  *
1123
1139
  * @method
1124
1140
  * @param {object} [options] Optional settings.
1125
- * @param {WriteConcern} [options.writeConcern] A full WriteConcern object
1126
- * @param {(number|string)} [options.w] The write concern
1127
- * @param {number} [options.wtimeout] The write concern timeout
1128
- * @param {boolean} [options.j] The journal write concern
1141
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1142
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1143
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1144
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1129
1145
  * @param {ClientSession} [options.session] optional session to use for this operation
1130
1146
  * @param {Collection~resultCallback} [callback] The results callback
1131
1147
  * @return {Promise} returns Promise if no callback passed
@@ -1184,9 +1200,10 @@ Collection.prototype.isCapped = function(options, callback) {
1184
1200
  * @method
1185
1201
  * @param {(string|array|object)} fieldOrSpec Defines the index.
1186
1202
  * @param {object} [options] Optional settings.
1187
- * @param {(number|string)} [options.w] The write concern.
1188
- * @param {number} [options.wtimeout] The write concern timeout.
1189
- * @param {boolean} [options.j=false] Specify a journal write concern.
1203
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1204
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1205
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1206
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1190
1207
  * @param {boolean} [options.unique=false] Creates an unique index.
1191
1208
  * @param {boolean} [options.sparse=false] Creates a sparse index.
1192
1209
  * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible.
@@ -1297,9 +1314,10 @@ Collection.prototype.createIndexes = function(indexSpecs, options, callback) {
1297
1314
  * @method
1298
1315
  * @param {string} indexName Name of the index to drop.
1299
1316
  * @param {object} [options] Optional settings.
1300
- * @param {(number|string)} [options.w] The write concern.
1301
- * @param {number} [options.wtimeout] The write concern timeout.
1302
- * @param {boolean} [options.j=false] Specify a journal write concern.
1317
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1318
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1319
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1320
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1303
1321
  * @param {ClientSession} [options.session] optional session to use for this operation
1304
1322
  * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1305
1323
  * @param {Collection~resultCallback} [callback] The command result callback
@@ -1395,9 +1413,10 @@ Collection.prototype.listIndexes = function(options) {
1395
1413
  * @deprecated use createIndexes instead
1396
1414
  * @param {(string|object)} fieldOrSpec Defines the index.
1397
1415
  * @param {object} [options] Optional settings.
1398
- * @param {(number|string)} [options.w] The write concern.
1399
- * @param {number} [options.wtimeout] The write concern timeout.
1400
- * @param {boolean} [options.j=false] Specify a journal write concern.
1416
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1417
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1418
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1419
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1401
1420
  * @param {boolean} [options.unique=false] Creates an unique index.
1402
1421
  * @param {boolean} [options.sparse=false] Creates a sparse index.
1403
1422
  * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible.
@@ -1580,6 +1599,7 @@ Collection.prototype.countDocuments = function(query, options, callback) {
1580
1599
  * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
1581
1600
  * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1582
1601
  * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}.
1602
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
1583
1603
  * @param {ClientSession} [options.session] optional session to use for this operation
1584
1604
  * @param {Collection~resultCallback} [callback] The command result callback
1585
1605
  * @return {Promise} returns Promise if no callback passed
@@ -1659,6 +1679,7 @@ Collection.prototype.stats = function(options, callback) {
1659
1679
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
1660
1680
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
1661
1681
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
1682
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
1662
1683
  * @param {ClientSession} [options.session] optional session to use for this operation
1663
1684
  * @param {Collection~findAndModifyCallback} [callback] The collection result callback
1664
1685
  * @return {Promise<Collection~findAndModifyWriteOpResultObject>} returns Promise if no callback passed
@@ -1667,6 +1688,12 @@ Collection.prototype.findOneAndDelete = function(filter, options, callback) {
1667
1688
  if (typeof options === 'function') (callback = options), (options = {});
1668
1689
  options = options || {};
1669
1690
 
1691
+ // Add ignoreUndefined
1692
+ if (this.s.options.ignoreUndefined) {
1693
+ options = Object.assign({}, options);
1694
+ options.ignoreUndefined = this.s.options.ignoreUndefined;
1695
+ }
1696
+
1670
1697
  return executeOperation(
1671
1698
  this.s.topology,
1672
1699
  new FindOneAndDeleteOperation(this, filter, options),
@@ -1692,6 +1719,7 @@ Collection.prototype.findOneAndDelete = function(filter, options, callback) {
1692
1719
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
1693
1720
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
1694
1721
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
1722
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
1695
1723
  * @param {ClientSession} [options.session] optional session to use for this operation
1696
1724
  * @param {Collection~findAndModifyCallback} [callback] The collection result callback
1697
1725
  * @return {Promise<Collection~findAndModifyWriteOpResultObject>} returns Promise if no callback passed
@@ -1700,6 +1728,12 @@ Collection.prototype.findOneAndReplace = function(filter, replacement, options,
1700
1728
  if (typeof options === 'function') (callback = options), (options = {});
1701
1729
  options = options || {};
1702
1730
 
1731
+ // Add ignoreUndefined
1732
+ if (this.s.options.ignoreUndefined) {
1733
+ options = Object.assign({}, options);
1734
+ options.ignoreUndefined = this.s.options.ignoreUndefined;
1735
+ }
1736
+
1703
1737
  return executeOperation(
1704
1738
  this.s.topology,
1705
1739
  new FindOneAndReplaceOperation(this, filter, replacement, options),
@@ -1726,6 +1760,7 @@ Collection.prototype.findOneAndReplace = function(filter, replacement, options,
1726
1760
  * @param {boolean} [options.checkKeys=false] If true, will throw if bson documents start with `$` or include a `.` in any key value
1727
1761
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
1728
1762
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
1763
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
1729
1764
  * @param {ClientSession} [options.session] An ptional session to use for this operation
1730
1765
  * @param {Collection~findAndModifyCallback} [callback] The collection result callback
1731
1766
  * @return {Promise<Collection~findAndModifyWriteOpResultObject>} returns Promise if no callback passed
@@ -1734,6 +1769,12 @@ Collection.prototype.findOneAndUpdate = function(filter, update, options, callba
1734
1769
  if (typeof options === 'function') (callback = options), (options = {});
1735
1770
  options = options || {};
1736
1771
 
1772
+ // Add ignoreUndefined
1773
+ if (this.s.options.ignoreUndefined) {
1774
+ options = Object.assign({}, options);
1775
+ options.ignoreUndefined = this.s.options.ignoreUndefined;
1776
+ }
1777
+
1737
1778
  return executeOperation(
1738
1779
  this.s.topology,
1739
1780
  new FindOneAndUpdateOperation(this, filter, update, options),
@@ -1748,9 +1789,10 @@ Collection.prototype.findOneAndUpdate = function(filter, update, options, callba
1748
1789
  * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
1749
1790
  * @param {object} doc The fields/vals to be updated.
1750
1791
  * @param {object} [options] Optional settings.
1751
- * @param {(number|string)} [options.w] The write concern.
1752
- * @param {number} [options.wtimeout] The write concern timeout.
1753
- * @param {boolean} [options.j=false] Specify a journal write concern.
1792
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1793
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1794
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1795
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1754
1796
  * @param {boolean} [options.remove=false] Set to true to remove the object before returning.
1755
1797
  * @param {boolean} [options.upsert=false] Perform an upsert operation.
1756
1798
  * @param {boolean} [options.new=false] Set to true if you want to return the modified object rather than the original. Ignored for remove.
@@ -1798,9 +1840,10 @@ function _findAndModify(query, sort, doc, options, callback) {
1798
1840
  * @param {object} query Query object to locate the object to modify.
1799
1841
  * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
1800
1842
  * @param {object} [options] Optional settings.
1801
- * @param {(number|string)} [options.w] The write concern.
1802
- * @param {number} [options.wtimeout] The write concern timeout.
1803
- * @param {boolean} [options.j=false] Specify a journal write concern.
1843
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
1844
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
1845
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
1846
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
1804
1847
  * @param {ClientSession} [options.session] optional session to use for this operation
1805
1848
  * @param {Collection~resultCallback} [callback] The command result callback
1806
1849
  * @return {Promise} returns Promise if no callback passed
@@ -1831,7 +1874,6 @@ Collection.prototype.findAndRemove = deprecate(function(query, sort, options, ca
1831
1874
  * @param {number} [options.batchSize=1000] The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}.
1832
1875
  * @param {object} [options.cursor] Return the query as cursor, on 2.6 > it returns as a real cursor on pre 2.6 it returns as an emulated cursor.
1833
1876
  * @param {number} [options.cursor.batchSize=1000] Deprecated. Use `options.batchSize`
1834
- * @param {boolean} [options.explain=false] Explain returns the aggregation execution plan (requires mongodb 2.6 >).
1835
1877
  * @param {boolean} [options.allowDiskUse=false] allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 >).
1836
1878
  * @param {number} [options.maxTimeMS] maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.
1837
1879
  * @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.
@@ -1843,6 +1885,7 @@ Collection.prototype.findAndRemove = deprecate(function(query, sort, options, ca
1843
1885
  * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}.
1844
1886
  * @param {string} [options.comment] Add a comment to an aggregation command
1845
1887
  * @param {string|object} [options.hint] Add an index selection hint to an aggregation command
1888
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
1846
1889
  * @param {ClientSession} [options.session] optional session to use for this operation
1847
1890
  * @param {Collection~aggregationCallback} callback The command result callback
1848
1891
  * @return {(null|AggregationCursor)}
@@ -2089,6 +2132,7 @@ Collection.prototype.group = deprecate(function(
2089
2132
  * @param {boolean} [options.jsMode=false] It is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X.
2090
2133
  * @param {boolean} [options.verbose=false] Provide statistics on job execution time.
2091
2134
  * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher.
2135
+ * @param {'queryPlanner'|'queryPlannerExtended'|'executionStats'|'allPlansExecution'|boolean} [options.explain] The verbosity mode for the explain output.
2092
2136
  * @param {ClientSession} [options.session] optional session to use for this operation
2093
2137
  * @param {Collection~resultCallback} [callback] The command result callback
2094
2138
  * @throws {MongoError}
@@ -2124,9 +2168,10 @@ Collection.prototype.mapReduce = function(map, reduce, options, callback) {
2124
2168
  *
2125
2169
  * @method
2126
2170
  * @param {object} [options] Optional settings.
2127
- * @param {(number|string)} [options.w] The write concern.
2128
- * @param {number} [options.wtimeout] The write concern timeout.
2129
- * @param {boolean} [options.j=false] Specify a journal write concern.
2171
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
2172
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
2173
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
2174
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
2130
2175
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
2131
2176
  * @param {ClientSession} [options.session] optional session to use for this operation
2132
2177
  * @return {UnorderedBulkOperation}
@@ -2147,9 +2192,10 @@ Collection.prototype.initializeUnorderedBulkOp = function(options) {
2147
2192
  *
2148
2193
  * @method
2149
2194
  * @param {object} [options] Optional settings.
2150
- * @param {(number|string)} [options.w] The write concern.
2151
- * @param {number} [options.wtimeout] The write concern timeout.
2152
- * @param {boolean} [options.j=false] Specify a journal write concern.
2195
+ * @param {(number|string)} [options.w] **Deprecated** The write concern. Use writeConcern instead.
2196
+ * @param {number} [options.wtimeout] **Deprecated** The write concern timeout. Use writeConcern instead.
2197
+ * @param {boolean} [options.j=false] **Deprecated** Specify a journal write concern. Use writeConcern instead.
2198
+ * @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
2153
2199
  * @param {ClientSession} [options.session] optional session to use for this operation
2154
2200
  * @param {boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
2155
2201
  * @param {OrderedBulkOperation} callback The command result callback
@@ -11,6 +11,7 @@ const executeOperation = require('../operations/execute_operation');
11
11
  const Readable = require('stream').Readable;
12
12
  const SUPPORTS = require('../utils').SUPPORTS;
13
13
  const MongoDBNamespace = require('../utils').MongoDBNamespace;
14
+ const mergeOptions = require('../utils').mergeOptions;
14
15
  const OperationBase = require('../operations/operation').OperationBase;
15
16
 
16
17
  const BSON = retrieveBSON();
@@ -207,7 +208,9 @@ class CoreCursor extends Readable {
207
208
  * @return {Cursor}
208
209
  */
209
210
  clone() {
210
- return this.topology.cursor(this.ns, this.cmd, this.options);
211
+ const clonedOptions = mergeOptions({}, this.options);
212
+ delete clonedOptions.session;
213
+ return this.topology.cursor(this.ns, this.cmd, clonedOptions);
211
214
  }
212
215
 
213
216
  /**