mongodb 3.2.2 → 3.2.6

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.
package/HISTORY.md CHANGED
@@ -2,6 +2,62 @@
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
+ <a name="3.2.6"></a>
6
+ ## [3.2.6](https://github.com/mongodb/node-mongodb-native/compare/v3.2.5...v3.2.6) (2019-05-24)
7
+
8
+
9
+
10
+ <a name="3.2.5"></a>
11
+ ## [3.2.5](https://github.com/mongodb/node-mongodb-native/compare/v3.2.4...v3.2.5) (2019-05-17)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **core:** updating core to 3.2.5 ([a2766c1](https://github.com/mongodb/node-mongodb-native/commit/a2766c1))
17
+
18
+
19
+
20
+ <a name="3.2.4"></a>
21
+ ## [3.2.4](https://github.com/mongodb/node-mongodb-native/compare/v3.2.2...v3.2.4) (2019-05-08)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * **aggregation:** fix field name typo ([4235d04](https://github.com/mongodb/node-mongodb-native/commit/4235d04))
27
+ * **async:** rewrote asyncGenerator in node < 10 syntax ([49c8cef](https://github.com/mongodb/node-mongodb-native/commit/49c8cef))
28
+ * **BulkOp:** run unordered bulk ops in serial ([f548bd7](https://github.com/mongodb/node-mongodb-native/commit/f548bd7))
29
+ * **bulkWrite:** fix issue with bulkWrite continuing w/ callback ([2a4a42c](https://github.com/mongodb/node-mongodb-native/commit/2a4a42c))
30
+ * **docs:** correctly document that default for `sslValidate` is false ([1f8e7fa](https://github.com/mongodb/node-mongodb-native/commit/1f8e7fa))
31
+ * **gridfs-stream:** honor chunk size ([9eeb114](https://github.com/mongodb/node-mongodb-native/commit/9eeb114))
32
+ * **unified-topology:** only clone pool size if provided ([8dc2416](https://github.com/mongodb/node-mongodb-native/commit/8dc2416))
33
+
34
+
35
+ ### Features
36
+
37
+ * update to mongodb-core v3.2.3 ([1c5357a](https://github.com/mongodb/node-mongodb-native/commit/1c5357a))
38
+ * **core:** update to mongodb-core v3.2.4 ([2059260](https://github.com/mongodb/node-mongodb-native/commit/2059260))
39
+ * **lib:** implement executeOperationV2 ([67d4edf](https://github.com/mongodb/node-mongodb-native/commit/67d4edf))
40
+
41
+
42
+
43
+ <a name="3.2.3"></a>
44
+ ## [3.2.3](https://github.com/mongodb/node-mongodb-native/compare/v3.2.2...v3.2.3) (2019-04-05)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * **aggregation:** fix field name typo ([4235d04](https://github.com/mongodb/node-mongodb-native/commit/4235d04))
50
+ * **async:** rewrote asyncGenerator in node < 10 syntax ([49c8cef](https://github.com/mongodb/node-mongodb-native/commit/49c8cef))
51
+ * **bulkWrite:** fix issue with bulkWrite continuing w/ callback ([2a4a42c](https://github.com/mongodb/node-mongodb-native/commit/2a4a42c))
52
+ * **docs:** correctly document that default for `sslValidate` is false ([1f8e7fa](https://github.com/mongodb/node-mongodb-native/commit/1f8e7fa))
53
+
54
+
55
+ ### Features
56
+
57
+ * update to mongodb-core v3.2.3 ([1c5357a](https://github.com/mongodb/node-mongodb-native/commit/1c5357a))
58
+
59
+
60
+
5
61
  <a name="3.2.2"></a>
6
62
  ## [3.2.2](https://github.com/mongodb/node-mongodb-native/compare/v3.2.1...v3.2.2) (2019-03-22)
7
63
 
package/README.md CHANGED
@@ -31,10 +31,9 @@ case in our issue management tool, JIRA:
31
31
  Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the
32
32
  Core Server (i.e. SERVER) project are **public**.
33
33
 
34
- ### Questions and Bug Reports
34
+ ### Support / Feedback
35
35
 
36
- * Mailing List: [groups.google.com/forum/#!forum/node-mongodb-native](https://groups.google.com/forum/#!forum/node-mongodb-native)
37
- * JIRA: [jira.mongodb.org](http://jira.mongodb.org)
36
+ For issues with, questions about, or feedback for the Node.js driver, please look into our [support channels](http://www.mongodb.org/about/support). Please do not email any of the driver developers directly with issues or questions - you're more likely to get an answer on the [mongodb-user](http://groups.google.com/group/mongodb-user>) list on Google Groups.
38
37
 
39
38
  ### Change Log
40
39
 
package/lib/.DS_Store ADDED
Binary file
@@ -148,7 +148,7 @@ AggregationCursor.prototype.batchSize = function(value) {
148
148
  if (this.s.state === AggregationCursor.CLOSED || this.isDead())
149
149
  throw MongoError.create({ message: 'Cursor is closed', driver: true });
150
150
  if (typeof value !== 'number')
151
- throw MongoError.create({ message: 'batchSize requires an integer', drvier: true });
151
+ throw MongoError.create({ message: 'batchSize requires an integer', driver: true });
152
152
  if (this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value;
153
153
  this.setCursorBatchSize(value);
154
154
  return this;
@@ -326,7 +326,7 @@ AggregationCursor.prototype.get = AggregationCursor.prototype.toArray;
326
326
  /**
327
327
  * Returns an array of documents. The caller is responsible for making sure that there
328
328
  * is enough memory to store the results. Note that the array only contain partial
329
- * results when this cursor had been previouly accessed. In that case,
329
+ * results when this cursor had been previously accessed. In that case,
330
330
  * cursor.rewind() can be used to reset the cursor.
331
331
  * @method AggregationCursor.prototype.toArray
332
332
  * @param {AggregationCursor~toArrayResultCallback} [callback] The result callback.
@@ -343,7 +343,7 @@ AggregationCursor.prototype.get = AggregationCursor.prototype.toArray;
343
343
 
344
344
  /**
345
345
  * Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
346
- * not all of the elements will be iterated if this cursor had been previouly accessed.
346
+ * not all of the elements will be iterated if this cursor had been previously accessed.
347
347
  * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike
348
348
  * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements
349
349
  * at any given time if batch size is specified. Otherwise, the caller is responsible
@@ -1,15 +1,33 @@
1
1
  'use strict';
2
2
 
3
- async function* asyncIterator() {
4
- while (true) {
5
- const value = await this.next();
6
- if (!value) {
7
- await this.close();
8
- return;
9
- }
3
+ // async function* asyncIterator() {
4
+ // while (true) {
5
+ // const value = await this.next();
6
+ // if (!value) {
7
+ // await this.close();
8
+ // return;
9
+ // }
10
+
11
+ // yield value;
12
+ // }
13
+ // }
10
14
 
11
- yield value;
12
- }
15
+ // TODO: change this to the async generator function above
16
+ function asyncIterator() {
17
+ const cursor = this;
18
+
19
+ return {
20
+ next: function() {
21
+ return Promise.resolve()
22
+ .then(() => cursor.next())
23
+ .then(value => {
24
+ if (!value) {
25
+ return cursor.close().then(() => ({ value, done: true }));
26
+ }
27
+ return { value, done: false };
28
+ });
29
+ }
30
+ };
13
31
  }
14
32
 
15
33
  exports.asyncIterator = asyncIterator;
@@ -2,18 +2,18 @@
2
2
 
3
3
  const Long = require('mongodb-core').BSON.Long;
4
4
  const MongoError = require('mongodb-core').MongoError;
5
+ const ObjectID = require('mongodb-core').BSON.ObjectID;
6
+ const BSON = require('mongodb-core').BSON;
7
+ const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError;
5
8
  const toError = require('../utils').toError;
6
9
  const handleCallback = require('../utils').handleCallback;
7
10
  const applyRetryableWrites = require('../utils').applyRetryableWrites;
8
11
  const applyWriteConcern = require('../utils').applyWriteConcern;
9
- const ObjectID = require('mongodb-core').BSON.ObjectID;
10
- const BSON = require('mongodb-core').BSON;
12
+ const executeOperation = require('../utils').executeOperation;
13
+ const isPromiseLike = require('../utils').isPromiseLike;
11
14
 
12
15
  // Error codes
13
- const UNKNOWN_ERROR = 8;
14
- const INVALID_BSON_ERROR = 22;
15
16
  const WRITE_CONCERN_ERROR = 64;
16
- const MULTIPLE_ERROR = 65;
17
17
 
18
18
  // Insert types
19
19
  const INSERT = 1;
@@ -54,18 +54,6 @@ class Batch {
54
54
  }
55
55
  }
56
56
 
57
- /**
58
- * Wraps a legacy operation so we can correctly rewrite it's error
59
- * @ignore
60
- */
61
- class LegacyOp {
62
- constructor(batchType, operation, index) {
63
- this.batchType = batchType;
64
- this.index = index;
65
- this.operation = operation;
66
- }
67
- }
68
-
69
57
  /**
70
58
  * Create a new BulkWriteResult instance (INTERNAL TYPE, do not instantiate directly)
71
59
  *
@@ -352,7 +340,7 @@ class WriteError {
352
340
  * Merges results into shared data structure
353
341
  * @ignore
354
342
  */
355
- function mergeBatchResults(ordered, batch, bulkResult, err, result) {
343
+ function mergeBatchResults(batch, bulkResult, err, result) {
356
344
  // If we have an error set the result to be the err object
357
345
  if (err) {
358
346
  result = err;
@@ -484,6 +472,41 @@ function mergeBatchResults(ordered, batch, bulkResult, err, result) {
484
472
  }
485
473
  }
486
474
 
475
+ function executeCommands(bulkOperation, options, callback) {
476
+ if (bulkOperation.s.batches.length === 0) {
477
+ return handleCallback(callback, null, new BulkWriteResult(bulkOperation.s.bulkResult));
478
+ }
479
+
480
+ const batch = bulkOperation.s.batches.shift();
481
+
482
+ function resultHandler(err, result) {
483
+ // Error is a driver related error not a bulk op error, terminate
484
+ if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
485
+ return handleCallback(callback, err);
486
+ }
487
+
488
+ // If we have and error
489
+ if (err) err.ok = 0;
490
+ if (err instanceof MongoWriteConcernError) {
491
+ return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, err, callback);
492
+ }
493
+
494
+ // Merge the results together
495
+ const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
496
+ const mergeResult = mergeBatchResults(batch, bulkOperation.s.bulkResult, err, result);
497
+ if (mergeResult != null) {
498
+ return handleCallback(callback, null, writeResult);
499
+ }
500
+
501
+ if (bulkOperation.handleWriteError(callback, writeResult)) return;
502
+
503
+ // Execute the next command in line
504
+ executeCommands(bulkOperation, options, callback);
505
+ }
506
+
507
+ bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
508
+ }
509
+
487
510
  /**
488
511
  * handles write concern error
489
512
  *
@@ -493,8 +516,8 @@ function mergeBatchResults(ordered, batch, bulkResult, err, result) {
493
516
  * @param {WriteConcernError} err
494
517
  * @param {function} callback
495
518
  */
496
- function handleMongoWriteConcernError(batch, bulkResult, ordered, err, callback) {
497
- mergeBatchResults(ordered, batch, bulkResult, null, err.result);
519
+ function handleMongoWriteConcernError(batch, bulkResult, err, callback) {
520
+ mergeBatchResults(batch, bulkResult, null, err.result);
498
521
 
499
522
  const wrappedWriteConcernError = new WriteConcernError({
500
523
  errmsg: err.result.writeConcernError.errmsg,
@@ -906,6 +929,15 @@ class BulkOperationBase {
906
929
  );
907
930
  }
908
931
 
932
+ _handleEarlyError(err, callback) {
933
+ if (typeof callback === 'function') {
934
+ callback(err, null);
935
+ return;
936
+ }
937
+
938
+ return this.s.promiseLibrary.reject(err);
939
+ }
940
+
909
941
  /**
910
942
  * Execute next write command in a chain
911
943
  *
@@ -919,19 +951,17 @@ class BulkOperationBase {
919
951
  if (typeof options === 'function') (callback = options), (options = {});
920
952
  options = options || {};
921
953
 
922
- if (this.s.executed) {
923
- const executedError = toError('batch cannot be re-executed');
924
- return typeof callback === 'function'
925
- ? callback(executedError, null)
926
- : this.s.promiseLibrary.reject(executedError);
927
- }
928
-
929
954
  if (typeof _writeConcern === 'function') {
930
955
  callback = _writeConcern;
931
956
  } else if (_writeConcern && typeof _writeConcern === 'object') {
932
957
  this.s.writeConcern = _writeConcern;
933
958
  }
934
959
 
960
+ if (this.s.executed) {
961
+ const executedError = toError('batch cannot be re-executed');
962
+ return this._handleEarlyError(executedError, callback);
963
+ }
964
+
935
965
  // If we have current batch
936
966
  if (this.isOrdered) {
937
967
  if (this.s.currentBatch) this.s.batches.push(this.s.currentBatch);
@@ -943,13 +973,43 @@ class BulkOperationBase {
943
973
  // If we have no operations in the bulk raise an error
944
974
  if (this.s.batches.length === 0) {
945
975
  const emptyBatchError = toError('Invalid Operation, no operations specified');
946
- return typeof callback === 'function'
947
- ? callback(emptyBatchError, null)
948
- : this.s.promiseLibrary.reject(emptyBatchError);
976
+ return this._handleEarlyError(emptyBatchError, callback);
949
977
  }
950
978
  return { options, callback };
951
979
  }
952
980
 
981
+ /**
982
+ * The callback format for results
983
+ * @callback BulkOperationBase~resultCallback
984
+ * @param {MongoError} error An error instance representing the error during the execution.
985
+ * @param {BulkWriteResult} result The bulk write result.
986
+ */
987
+ /**
988
+ * Execute the ordered bulk operation
989
+ *
990
+ * @method
991
+ * @param {object} [options] Optional settings.
992
+ * @param {(number|string)} [options.w] The write concern.
993
+ * @param {number} [options.wtimeout] The write concern timeout.
994
+ * @param {boolean} [options.j=false] Specify a journal write concern.
995
+ * @param {boolean} [options.fsync=false] Specify a file sync write concern.
996
+ * @param {BulkOperationBase~resultCallback} [callback] The result callback
997
+ * @throws {MongoError} Throws error if the bulk object has already been executed
998
+ * @throws {MongoError} Throws error if the bulk object does not have any operations
999
+ * @return {Promise} returns Promise if no callback passed
1000
+ */
1001
+ execute(_writeConcern, options, callback) {
1002
+ const ret = this.bulkExecute(_writeConcern, options, callback);
1003
+ if (!ret || isPromiseLike(ret)) {
1004
+ return ret;
1005
+ }
1006
+
1007
+ options = ret.options;
1008
+ callback = ret.callback;
1009
+
1010
+ return executeOperation(this.s.topology, executeCommands, [this, options, callback]);
1011
+ }
1012
+
953
1013
  /**
954
1014
  * Handles final options before executing command
955
1015
  *
@@ -1033,11 +1093,7 @@ class BulkOperationBase {
1033
1093
  // Force top level error
1034
1094
  err.ok = 0;
1035
1095
  // Merge top level error and return
1036
- handleCallback(
1037
- callback,
1038
- null,
1039
- mergeBatchResults(false, config.batch, this.s.bulkResult, err, null)
1040
- );
1096
+ handleCallback(callback, null, mergeBatchResults(config.batch, this.s.bulkResult, err, null));
1041
1097
  }
1042
1098
  }
1043
1099
 
@@ -1094,20 +1150,8 @@ Object.defineProperty(BulkOperationBase.prototype, 'length', {
1094
1150
  module.exports = {
1095
1151
  Batch,
1096
1152
  BulkOperationBase,
1097
- BulkWriteError,
1098
- BulkWriteResult,
1099
1153
  bson,
1100
- FindOperators,
1101
- handleMongoWriteConcernError,
1102
- LegacyOp,
1103
- mergeBatchResults,
1104
- INVALID_BSON_ERROR: INVALID_BSON_ERROR,
1105
- MULTIPLE_ERROR: MULTIPLE_ERROR,
1106
- UNKNOWN_ERROR: UNKNOWN_ERROR,
1107
- WRITE_CONCERN_ERROR: WRITE_CONCERN_ERROR,
1108
1154
  INSERT: INSERT,
1109
1155
  UPDATE: UPDATE,
1110
- REMOVE: REMOVE,
1111
- WriteError,
1112
- WriteConcernError
1156
+ REMOVE: REMOVE
1113
1157
  };
@@ -2,17 +2,10 @@
2
2
 
3
3
  const common = require('./common');
4
4
  const BulkOperationBase = common.BulkOperationBase;
5
- const utils = require('../utils');
6
- const toError = utils.toError;
7
- const handleCallback = utils.handleCallback;
8
- const BulkWriteResult = common.BulkWriteResult;
9
5
  const Batch = common.Batch;
10
- const mergeBatchResults = common.mergeBatchResults;
11
- const executeOperation = utils.executeOperation;
12
- const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError;
13
- const handleMongoWriteConcernError = require('./common').handleMongoWriteConcernError;
14
6
  const bson = common.bson;
15
- const isPromiseLike = require('../utils').isPromiseLike;
7
+ const utils = require('../utils');
8
+ const toError = utils.toError;
16
9
 
17
10
  /**
18
11
  * Add to internal list of Operations
@@ -85,6 +78,7 @@ function addToOperationsList(bulkOperation, docType, document) {
85
78
  /**
86
79
  * Create a new OrderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly)
87
80
  * @class
81
+ * @extends BulkOperationBase
88
82
  * @property {number} length Get the number of operations in the bulk.
89
83
  * @return {OrderedBulkOperation} a OrderedBulkOperation instance.
90
84
  */
@@ -96,81 +90,6 @@ class OrderedBulkOperation extends BulkOperationBase {
96
90
 
97
91
  super(topology, collection, options, true);
98
92
  }
99
-
100
- /**
101
- * The callback format for results
102
- * @callback OrderedBulkOperation~resultCallback
103
- * @param {MongoError} error An error instance representing the error during the execution.
104
- * @param {BulkWriteResult} result The bulk write result.
105
- */
106
-
107
- /**
108
- * Execute the ordered bulk operation
109
- *
110
- * @method
111
- * @param {object} [options] Optional settings.
112
- * @param {(number|string)} [options.w] The write concern.
113
- * @param {number} [options.wtimeout] The write concern timeout.
114
- * @param {boolean} [options.j=false] Specify a journal write concern.
115
- * @param {boolean} [options.fsync=false] Specify a file sync write concern.
116
- * @param {OrderedBulkOperation~resultCallback} [callback] The result callback
117
- * @throws {MongoError}
118
- * @return {Promise} returns Promise if no callback passed
119
- */
120
- execute(_writeConcern, options, callback) {
121
- const ret = this.bulkExecute(_writeConcern, options, callback);
122
- if (isPromiseLike(ret)) {
123
- return ret;
124
- }
125
-
126
- options = ret.options;
127
- callback = ret.callback;
128
-
129
- return executeOperation(this.s.topology, executeCommands, [this, options, callback]);
130
- }
131
- }
132
-
133
- /**
134
- * Execute next write command in a chain
135
- *
136
- * @param {OrderedBulkOperation} bulkOperation
137
- * @param {object} options
138
- * @param {function} callback
139
- */
140
- function executeCommands(bulkOperation, options, callback) {
141
- if (bulkOperation.s.batches.length === 0) {
142
- return handleCallback(callback, null, new BulkWriteResult(bulkOperation.s.bulkResult));
143
- }
144
-
145
- // Ordered execution of the command
146
- const batch = bulkOperation.s.batches.shift();
147
-
148
- function resultHandler(err, result) {
149
- // Error is a driver related error not a bulk op error, terminate
150
- if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
151
- return handleCallback(callback, err);
152
- }
153
-
154
- // If we have and error
155
- if (err) err.ok = 0;
156
- if (err instanceof MongoWriteConcernError) {
157
- return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, true, err, callback);
158
- }
159
-
160
- // Merge the results together
161
- const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
162
- const mergeResult = mergeBatchResults(true, batch, bulkOperation.s.bulkResult, err, result);
163
- if (mergeResult != null) {
164
- return handleCallback(callback, null, writeResult);
165
- }
166
-
167
- if (bulkOperation.handleWriteError(callback, writeResult)) return;
168
-
169
- // Execute the next command in line
170
- executeCommands(bulkOperation, options, callback);
171
- }
172
-
173
- bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
174
93
  }
175
94
 
176
95
  /**
@@ -2,17 +2,10 @@
2
2
 
3
3
  const common = require('./common');
4
4
  const BulkOperationBase = common.BulkOperationBase;
5
- const utils = require('../utils');
6
- const toError = utils.toError;
7
- const handleCallback = utils.handleCallback;
8
- const BulkWriteResult = common.BulkWriteResult;
9
5
  const Batch = common.Batch;
10
- const mergeBatchResults = common.mergeBatchResults;
11
- const executeOperation = utils.executeOperation;
12
- const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError;
13
- const handleMongoWriteConcernError = require('./common').handleMongoWriteConcernError;
14
6
  const bson = common.bson;
15
- const isPromiseLike = require('../utils').isPromiseLike;
7
+ const utils = require('../utils');
8
+ const toError = utils.toError;
16
9
 
17
10
  /**
18
11
  * Add to internal list of Operations
@@ -98,6 +91,7 @@ function addToOperationsList(bulkOperation, docType, document) {
98
91
  /**
99
92
  * Create a new UnorderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly)
100
93
  * @class
94
+ * @extends BulkOperationBase
101
95
  * @property {number} length Get the number of operations in the bulk.
102
96
  * @return {UnorderedBulkOperation} a UnorderedBulkOperation instance.
103
97
  */
@@ -108,106 +102,6 @@ class UnorderedBulkOperation extends BulkOperationBase {
108
102
 
109
103
  super(topology, collection, options, false);
110
104
  }
111
-
112
- /**
113
- * The callback format for results
114
- * @callback UnorderedBulkOperation~resultCallback
115
- * @param {MongoError} error An error instance representing the error during the execution.
116
- * @param {BulkWriteResult} result The bulk write result.
117
- */
118
-
119
- /**
120
- * Execute the ordered bulk operation
121
- *
122
- * @method
123
- * @param {object} [options] Optional settings.
124
- * @param {(number|string)} [options.w] The write concern.
125
- * @param {number} [options.wtimeout] The write concern timeout.
126
- * @param {boolean} [options.j=false] Specify a journal write concern.
127
- * @param {boolean} [options.fsync=false] Specify a file sync write concern.
128
- * @param {UnorderedBulkOperation~resultCallback} [callback] The result callback
129
- * @throws {MongoError}
130
- * @return {Promise} returns Promise if no callback passed
131
- */
132
- execute(_writeConcern, options, callback) {
133
- const ret = this.bulkExecute(_writeConcern, options, callback);
134
- if (isPromiseLike(ret)) {
135
- return ret;
136
- }
137
-
138
- options = ret.options;
139
- callback = ret.callback;
140
-
141
- return executeOperation(this.s.topology, executeBatches, [this, options, callback]);
142
- }
143
- }
144
-
145
- /**
146
- * Execute the command
147
- *
148
- * @param {UnorderedBulkOperation} bulkOperation
149
- * @param {object} batch
150
- * @param {object} options
151
- * @param {function} callback
152
- */
153
- function executeBatch(bulkOperation, batch, options, callback) {
154
- function resultHandler(err, result) {
155
- // Error is a driver related error not a bulk op error, terminate
156
- if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
157
- return handleCallback(callback, err);
158
- }
159
-
160
- // If we have and error
161
- if (err) err.ok = 0;
162
- if (err instanceof MongoWriteConcernError) {
163
- return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, false, err, callback);
164
- }
165
- handleCallback(
166
- callback,
167
- null,
168
- mergeBatchResults(false, batch, bulkOperation.s.bulkResult, err, result)
169
- );
170
- }
171
-
172
- bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
173
- }
174
-
175
- /**
176
- * Execute all the commands
177
- *
178
- * @param {UnorderedBulkOperation} bulkOperation
179
- * @param {object} options
180
- * @param {function} callback
181
- */
182
- function executeBatches(bulkOperation, options, callback) {
183
- let numberOfCommandsToExecute = bulkOperation.s.batches.length;
184
- let hasErrored = false;
185
- // Execute over all the batches
186
- for (let i = 0; i < bulkOperation.s.batches.length; i++) {
187
- executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
188
- if (hasErrored) {
189
- return;
190
- }
191
-
192
- if (err) {
193
- hasErrored = true;
194
- return handleCallback(callback, err);
195
- }
196
- // Count down the number of commands left to execute
197
- numberOfCommandsToExecute = numberOfCommandsToExecute - 1;
198
-
199
- // Execute
200
- if (numberOfCommandsToExecute === 0) {
201
- // Driver level error
202
- if (err) return handleCallback(callback, err);
203
-
204
- const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
205
- if (bulkOperation.handleWriteError(callback, writeResult)) return;
206
-
207
- return handleCallback(callback, null, writeResult);
208
- }
209
- });
210
- }
211
105
  }
212
106
 
213
107
  /**
package/lib/collection.js CHANGED
@@ -268,7 +268,7 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot'];
268
268
  * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
269
269
  * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
270
270
  * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system
271
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
271
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
272
272
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
273
273
  * @param {ClientSession} [options.session] optional session to use for this operation
274
274
  * @throws {MongoError}
@@ -454,7 +454,7 @@ Collection.prototype.insertOne = function(doc, options, callback) {
454
454
  if (typeof options === 'function') (callback = options), (options = {});
455
455
  options = options || {};
456
456
 
457
- // Add ignoreUndfined
457
+ // Add ignoreUndefined
458
458
  if (this.s.options.ignoreUndefined) {
459
459
  options = Object.assign({}, options);
460
460
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -685,7 +685,7 @@ Collection.prototype.updateOne = function(filter, update, options, callback) {
685
685
 
686
686
  options = Object.assign({}, options);
687
687
 
688
- // Add ignoreUndfined
688
+ // Add ignoreUndefined
689
689
  if (this.s.options.ignoreUndefined) {
690
690
  options = Object.assign({}, options);
691
691
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -713,7 +713,7 @@ Collection.prototype.replaceOne = function(filter, doc, options, callback) {
713
713
  if (typeof options === 'function') (callback = options), (options = {});
714
714
  options = Object.assign({}, options);
715
715
 
716
- // Add ignoreUndfined
716
+ // Add ignoreUndefined
717
717
  if (this.s.options.ignoreUndefined) {
718
718
  options = Object.assign({}, options);
719
719
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -749,7 +749,7 @@ Collection.prototype.updateMany = function(filter, update, options, callback) {
749
749
 
750
750
  options = Object.assign({}, options);
751
751
 
752
- // Add ignoreUndfined
752
+ // Add ignoreUndefined
753
753
  if (this.s.options.ignoreUndefined) {
754
754
  options = Object.assign({}, options);
755
755
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -782,7 +782,7 @@ Collection.prototype.update = deprecate(function(selector, update, options, call
782
782
  if (typeof options === 'function') (callback = options), (options = {});
783
783
  options = options || {};
784
784
 
785
- // Add ignoreUndfined
785
+ // Add ignoreUndefined
786
786
  if (this.s.options.ignoreUndefined) {
787
787
  options = Object.assign({}, options);
788
788
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -829,7 +829,7 @@ Collection.prototype.deleteOne = function(filter, options, callback) {
829
829
  if (typeof options === 'function') (callback = options), (options = {});
830
830
  options = Object.assign({}, options);
831
831
 
832
- // Add ignoreUndfined
832
+ // Add ignoreUndefined
833
833
  if (this.s.options.ignoreUndefined) {
834
834
  options = Object.assign({}, options);
835
835
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -856,7 +856,7 @@ Collection.prototype.deleteMany = function(filter, options, callback) {
856
856
  if (typeof options === 'function') (callback = options), (options = {});
857
857
  options = Object.assign({}, options);
858
858
 
859
- // Add ignoreUndfined
859
+ // Add ignoreUndefined
860
860
  if (this.s.options.ignoreUndefined) {
861
861
  options = Object.assign({}, options);
862
862
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -885,7 +885,7 @@ Collection.prototype.remove = deprecate(function(selector, options, callback) {
885
885
  if (typeof options === 'function') (callback = options), (options = {});
886
886
  options = options || {};
887
887
 
888
- // Add ignoreUndfined
888
+ // Add ignoreUndefined
889
889
  if (this.s.options.ignoreUndefined) {
890
890
  options = Object.assign({}, options);
891
891
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -912,7 +912,7 @@ Collection.prototype.save = deprecate(function(doc, options, callback) {
912
912
  if (typeof options === 'function') (callback = options), (options = {});
913
913
  options = options || {};
914
914
 
915
- // Add ignoreUndfined
915
+ // Add ignoreUndefined
916
916
  if (this.s.options.ignoreUndefined) {
917
917
  options = Object.assign({}, options);
918
918
  options.ignoreUndefined = this.s.options.ignoreUndefined;
@@ -963,7 +963,7 @@ Collection.prototype.save = deprecate(function(doc, options, callback) {
963
963
  * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
964
964
  * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
965
965
  * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system
966
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
966
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
967
967
  * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
968
968
  * @param {ClientSession} [options.session] optional session to use for this operation
969
969
  * @param {Collection~resultCallback} [callback] The command result callback
@@ -1126,7 +1126,7 @@ Collection.prototype.createIndexes = function(indexSpecs, options, callback) {
1126
1126
  * @param {number} [options.wtimeout] The write concern timeout.
1127
1127
  * @param {boolean} [options.j=false] Specify a journal write concern.
1128
1128
  * @param {ClientSession} [options.session] optional session to use for this operation
1129
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
1129
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1130
1130
  * @param {Collection~resultCallback} [callback] The command result callback
1131
1131
  * @return {Promise} returns Promise if no callback passed
1132
1132
  */
@@ -1146,7 +1146,7 @@ Collection.prototype.dropIndex = function(indexName, options, callback) {
1146
1146
  * @method
1147
1147
  * @param {Object} [options] Optional settings
1148
1148
  * @param {ClientSession} [options.session] optional session to use for this operation
1149
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
1149
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1150
1150
  * @param {Collection~resultCallback} [callback] The command result callback
1151
1151
  * @return {Promise} returns Promise if no callback passed
1152
1152
  */
@@ -1318,7 +1318,7 @@ Collection.prototype.indexInformation = function(options, callback) {
1318
1318
  * @param {boolean} [options.skip] The number of documents to skip for the count.
1319
1319
  * @param {string} [options.hint] An index name hint for the query.
1320
1320
  * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
1321
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
1321
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1322
1322
  * @param {ClientSession} [options.session] optional session to use for this operation
1323
1323
  * @param {Collection~countCallback} [callback] The command result callback
1324
1324
  * @return {Promise} returns Promise if no callback passed
@@ -1398,7 +1398,7 @@ Collection.prototype.countDocuments = function(query, options, callback) {
1398
1398
  * @param {object} query The query for filtering the set of documents to which we apply the distinct filter.
1399
1399
  * @param {object} [options] Optional settings.
1400
1400
  * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
1401
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
1401
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
1402
1402
  * @param {ClientSession} [options.session] optional session to use for this operation
1403
1403
  * @param {Collection~resultCallback} [callback] The command result callback
1404
1404
  * @return {Promise} returns Promise if no callback passed
@@ -1587,7 +1587,18 @@ Collection.prototype.findOneAndUpdate = function(filter, update, options, callba
1587
1587
  * @return {Promise} returns Promise if no callback passed
1588
1588
  * @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead
1589
1589
  */
1590
- Collection.prototype.findAndModify = deprecate(function(query, sort, doc, options, callback) {
1590
+ Collection.prototype.findAndModify = deprecate(
1591
+ _findAndModify,
1592
+ 'collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.'
1593
+ );
1594
+
1595
+ /**
1596
+ * @ignore
1597
+ */
1598
+
1599
+ Collection.prototype._findAndModify = _findAndModify;
1600
+
1601
+ function _findAndModify(query, sort, doc, options, callback) {
1591
1602
  const args = Array.prototype.slice.call(arguments, 1);
1592
1603
  callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined;
1593
1604
  sort = args.length ? args.shift() || [] : [];
@@ -1607,7 +1618,7 @@ Collection.prototype.findAndModify = deprecate(function(query, sort, doc, option
1607
1618
  options,
1608
1619
  callback
1609
1620
  ]);
1610
- }, 'collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.');
1621
+ }
1611
1622
 
1612
1623
  /**
1613
1624
  * Find and remove a document.
@@ -259,7 +259,7 @@ CommandCursor.prototype.get = CommandCursor.prototype.toArray;
259
259
  /**
260
260
  * Returns an array of documents. The caller is responsible for making sure that there
261
261
  * is enough memory to store the results. Note that the array only contain partial
262
- * results when this cursor had been previouly accessed.
262
+ * results when this cursor had been previously accessed.
263
263
  * @method CommandCursor.prototype.toArray
264
264
  * @param {CommandCursor~toArrayResultCallback} [callback] The result callback.
265
265
  * @throws {MongoError}
@@ -275,7 +275,7 @@ CommandCursor.prototype.get = CommandCursor.prototype.toArray;
275
275
 
276
276
  /**
277
277
  * Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
278
- * not all of the elements will be iterated if this cursor had been previouly accessed.
278
+ * not all of the elements will be iterated if this cursor had been previously accessed.
279
279
  * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike
280
280
  * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements
281
281
  * at any given time if batch size is specified. Otherwise, the caller is responsible
package/lib/cursor.js CHANGED
@@ -693,7 +693,7 @@ Cursor.prototype.skip = function(value) {
693
693
 
694
694
  /**
695
695
  * Iterates over all the documents for this cursor. As with **{cursor.toArray}**,
696
- * not all of the elements will be iterated if this cursor had been previouly accessed.
696
+ * not all of the elements will be iterated if this cursor had been previously accessed.
697
697
  * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike
698
698
  * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements
699
699
  * at any given time if batch size is specified. Otherwise, the caller is responsible
@@ -811,7 +811,7 @@ Cursor.prototype.setReadPreference = function(readPreference) {
811
811
  /**
812
812
  * Returns an array of documents. The caller is responsible for making sure that there
813
813
  * is enough memory to store the results. Note that the array only contains partial
814
- * results when this cursor had been previouly accessed. In that case,
814
+ * results when this cursor had been previously accessed. In that case,
815
815
  * cursor.rewind() can be used to reset the cursor.
816
816
  * @method
817
817
  * @param {Cursor~toArrayResultCallback} [callback] The result callback.
@@ -845,7 +845,7 @@ Cursor.prototype.toArray = function(callback) {
845
845
  * @param {object} [options] Optional settings.
846
846
  * @param {number} [options.skip] The number of documents to skip.
847
847
  * @param {number} [options.limit] The maximum amounts to count before aborting.
848
- * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query.
848
+ * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
849
849
  * @param {string} [options.hint] An index name hint for the query.
850
850
  * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
851
851
  * @param {Cursor~countResultCallback} [callback] The result callback.
package/lib/db.js CHANGED
@@ -113,7 +113,7 @@ const legalOptionNames = [
113
113
  * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys.
114
114
  * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
115
115
  * @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
116
- * @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported)
116
+ * @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported)
117
117
  * @property {(Server|ReplSet|Mongos)} serverConfig Get the current db topology.
118
118
  * @property {number} bufferMaxEntries Current bufferMaxEntries value for the database
119
119
  * @property {string} databaseName The name of the database this instance represents.
@@ -355,7 +355,7 @@ const collectionKeys = [
355
355
  * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
356
356
  * @param {boolean} [options.strict=false] Returns an error if the collection does not exist
357
357
  * @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
358
- * @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported)
358
+ * @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported)
359
359
  * @param {Db~collectionResultCallback} [callback] The collection result callback
360
360
  * @return {Collection} return the new Collection instance if not in strict mode
361
361
  */
@@ -595,7 +595,7 @@ Db.prototype.listCollections = function(filter, options) {
595
595
  * @param {Code} code JavaScript to execute on server.
596
596
  * @param {(object|array)} parameters The parameters for the call.
597
597
  * @param {object} [options] Optional settings.
598
- * @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaulation of the javascript.
598
+ * @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaluation of the javascript.
599
599
  * @param {ClientSession} [options.session] optional session to use for this operation
600
600
  * @param {Db~resultCallback} [callback] The results callback
601
601
  * @deprecated Eval is deprecated on MongoDB 3.2 and forward
@@ -867,7 +867,7 @@ Db.prototype.setProfilingLevel = function(level, options, callback) {
867
867
  };
868
868
 
869
869
  /**
870
- * Retrive the current profiling information for MongoDB
870
+ * Retrieve the current profiling information for MongoDB
871
871
  *
872
872
  * @param {Object} [options] Optional settings
873
873
  * @param {ClientSession} [options.session] optional session to use for this operation
@@ -65,7 +65,7 @@ const deprecationFn = deprecate(() => {},
65
65
  *
66
66
  * Modes
67
67
  * - **"r"** - read only. This is the default mode.
68
- * - **"w"** - write in truncate mode. Existing data will be overwriten.
68
+ * - **"w"** - write in truncate mode. Existing data will be overwritten.
69
69
  *
70
70
  * @class
71
71
  * @param {Db} db A database instance to interact with.
@@ -234,13 +234,12 @@ function doRead(_this) {
234
234
  _this.s.bytesToSkip = 0;
235
235
  }
236
236
 
237
- if (expectedN === _this.s.expectedEnd && _this.s.bytesToTrim != null) {
238
- sliceEnd = _this.s.bytesToTrim;
239
- }
240
-
241
- // If the remaining amount of data left is < chunkSize read the right amount of data
242
- if (_this.s.options.end && _this.s.options.end - _this.s.bytesToSkip < buf.length) {
243
- sliceEnd = _this.s.options.end - _this.s.bytesToSkip;
237
+ const atEndOfStream = expectedN === _this.s.expectedEnd - 1;
238
+ const bytesLeftToRead = _this.s.options.end - _this.s.bytesToSkip;
239
+ if (atEndOfStream && _this.s.bytesToTrim != null) {
240
+ sliceEnd = _this.s.file.chunkSize - _this.s.bytesToTrim;
241
+ } else if (_this.s.options.end && bytesLeftToRead < doc.data.length()) {
242
+ sliceEnd = bytesLeftToRead;
244
243
  }
245
244
 
246
245
  if (sliceStart != null || sliceEnd != null) {
@@ -46,6 +46,12 @@ const closeOperation = require('./operations/mongo_client_ops').closeOperation;
46
46
  * });
47
47
  */
48
48
 
49
+ /**
50
+ * A string specifying the level of a ReadConcern
51
+ * @typedef {'local'|'available'|'majority'|'linearizable'|'snapshot'} ReadConcernLevel
52
+ * @see https://docs.mongodb.com/manual/reference/read-concern/index.html#read-concern-levels
53
+ */
54
+
49
55
  /**
50
56
  * Creates a new MongoClient instance
51
57
  * @class
@@ -53,7 +59,7 @@ const closeOperation = require('./operations/mongo_client_ops').closeOperation;
53
59
  * @param {object} [options] Optional settings
54
60
  * @param {number} [options.poolSize=5] The maximum size of the individual server pool
55
61
  * @param {boolean} [options.ssl=false] Enable SSL connection.
56
- * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against Certificate Authority
62
+ * @param {boolean} [options.sslValidate=false] Validate mongod server certificate against Certificate Authority
57
63
  * @param {buffer} [options.sslCA=undefined] SSL Certificate store binary buffer
58
64
  * @param {buffer} [options.sslCert=undefined] SSL Certificate binary buffer
59
65
  * @param {buffer} [options.sslKey=undefined] SSL Key file binary buffer
@@ -88,7 +94,7 @@ const closeOperation = require('./operations/mongo_client_ops').closeOperation;
88
94
  * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys
89
95
  * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
90
96
  * @param {object} [options.readConcern] Specify a read concern for the collection (only MongoDB 3.2 or higher supported)
91
- * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported)
97
+ * @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported)
92
98
  * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed)
93
99
  * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug)
94
100
  * @param {object} [options.logger=undefined] Custom logger object
@@ -179,7 +185,7 @@ MongoClient.prototype.logout = deprecate(function(options, callback) {
179
185
  /**
180
186
  * Close the db and its underlying connections
181
187
  * @method
182
- * @param {boolean} force Force close, emitting no events
188
+ * @param {boolean} [force=false] Force close, emitting no events
183
189
  * @param {Db~noResultCallback} [callback] The result callback
184
190
  * @return {Promise} returns Promise if no callback passed
185
191
  */
@@ -265,7 +271,7 @@ MongoClient.prototype.isConnected = function(options) {
265
271
  * @param {object} [options] Optional settings
266
272
  * @param {number} [options.poolSize=5] The maximum size of the individual server pool
267
273
  * @param {boolean} [options.ssl=false] Enable SSL connection.
268
- * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against Certificate Authority
274
+ * @param {boolean} [options.sslValidate=false] Validate mongod server certificate against Certificate Authority
269
275
  * @param {buffer} [options.sslCA=undefined] SSL Certificate store binary buffer
270
276
  * @param {buffer} [options.sslCert=undefined] SSL Certificate binary buffer
271
277
  * @param {buffer} [options.sslKey=undefined] SSL Key file binary buffer
@@ -300,7 +306,7 @@ MongoClient.prototype.isConnected = function(options) {
300
306
  * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys
301
307
  * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
302
308
  * @param {object} [options.readConcern] Specify a read concern for the collection (only MongoDB 3.2 or higher supported)
303
- * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported)
309
+ * @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported)
304
310
  * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed)
305
311
  * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug)
306
312
  * @param {object} [options.logger=undefined] Custom logger object
@@ -81,7 +81,7 @@ const groupFunction =
81
81
  * @param {Collection~bulkWriteOpCallback} [callback] The command result callback
82
82
  */
83
83
  function bulkWrite(coll, operations, options, callback) {
84
- // Add ignoreUndfined
84
+ // Add ignoreUndefined
85
85
  if (coll.s.options.ignoreUndefined) {
86
86
  options = Object.assign({}, options);
87
87
  options.ignoreUndefined = coll.s.options.ignoreUndefined;
@@ -601,7 +601,7 @@ function listCollectionsTransforms(databaseName) {
601
601
  }
602
602
 
603
603
  /**
604
- * Retrive the current profiling information for MongoDB
604
+ * Retrieve the current profiling information for MongoDB
605
605
  *
606
606
  * @method
607
607
  * @param {Db} db The Db instance on which to retrieve the profiling info.
@@ -634,7 +634,7 @@ function generateCredentials(client, username, password, options) {
634
634
  options = Object.assign({}, options);
635
635
 
636
636
  // the default db to authenticate against is 'self'
637
- // if authententicate is called from a retry context, it may be another one, like admin
637
+ // if authenticate is called from a retry context, it may be another one, like admin
638
638
  const source = options.authSource || options.authdb || options.dbName;
639
639
 
640
640
  // authMechanism
@@ -70,7 +70,7 @@ var legalOptionNames = [
70
70
  * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for MongoS proxy selection
71
71
  * @param {boolean} [options.ssl=false] Use ssl connection (needs to have a mongod server with ssl support)
72
72
  * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function.
73
- * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
73
+ * @param {boolean} [options.sslValidate=false] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
74
74
  * @param {array} [options.sslCA] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
75
75
  * @param {array} [options.sslCRL] Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
76
76
  * @param {string} [options.ciphers] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info.
@@ -14,9 +14,10 @@ class NativeTopology extends Topology {
14
14
  {
15
15
  cursorFactory: Cursor,
16
16
  reconnect: false,
17
- emitError: options.emitError,
18
- size: options.poolSize,
19
- monitorCommands: options.monitorCommands
17
+ emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
18
+ size: typeof options.poolSize === 'number' ? options.poolSize : 5,
19
+ monitorCommands:
20
+ typeof options.monitorCommands === 'boolean' ? options.monitorCommands : false
20
21
  }
21
22
  );
22
23
 
@@ -80,7 +80,7 @@ var legalOptionNames = [
80
80
  * @param {number} [options.poolSize=5] Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons.
81
81
  * @param {boolean} [options.ssl=false] Use ssl connection (needs to have a mongod server with ssl support)
82
82
  * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function.
83
- * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
83
+ * @param {boolean} [options.sslValidate=false] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
84
84
  * @param {array} [options.sslCA] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
85
85
  * @param {array} [options.sslCRL] Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
86
86
  * @param {(Buffer|string)} [options.sslCert] String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher.
@@ -70,7 +70,7 @@ var legalOptionNames = [
70
70
  * @param {object} [options] Optional settings.
71
71
  * @param {number} [options.poolSize=5] Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons.
72
72
  * @param {boolean} [options.ssl=false] Use ssl connection (needs to have a mongod server with ssl support)
73
- * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
73
+ * @param {boolean} [options.sslValidate=false] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher)
74
74
  * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function.
75
75
  * @param {array} [options.sslCA] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
76
76
  * @param {array} [options.sslCRL] Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
package/lib/url_parser.js CHANGED
@@ -355,7 +355,7 @@ function parseConnectionString(url, options) {
355
355
  if (_host.indexOf('?') !== -1) _host = _host.split(/\?/)[0];
356
356
  }
357
357
 
358
- // No entry returned for duplicate servr
358
+ // No entry returned for duplicate server
359
359
  if (deduplicatedServers[_host + '_' + _port]) return null;
360
360
  deduplicatedServers[_host + '_' + _port] = 1;
361
361
 
package/lib/utils.js CHANGED
@@ -114,7 +114,7 @@ var checkCollectionName = function checkCollectionName(collectionName) {
114
114
  throw new MongoError("collection names must not start or end with '.'");
115
115
  }
116
116
 
117
- // Validate that we are not passing 0x00 in the colletion name
117
+ // Validate that we are not passing 0x00 in the collection name
118
118
  if (collectionName.indexOf('\x00') !== -1) {
119
119
  throw new MongoError('collection names cannot contain a null character');
120
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb",
3
- "version": "3.2.2",
3
+ "version": "3.2.6",
4
4
  "description": "The official MongoDB driver for Node.js",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  "official"
18
18
  ],
19
19
  "dependencies": {
20
- "mongodb-core": "3.2.2",
20
+ "mongodb-core": "3.2.6",
21
21
  "safe-buffer": "^5.1.2"
22
22
  },
23
23
  "devDependencies": {