mongodb 3.6.0 → 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.
- package/HISTORY.md +60 -71
- package/README.md +1 -3
- package/lib/admin.js +10 -8
- package/lib/aggregation_cursor.js +7 -8
- package/lib/bulk/common.js +5 -4
- package/lib/change_stream.js +1 -1
- package/lib/cmap/connection.js +3 -1
- package/lib/cmap/connection_pool.js +5 -15
- package/lib/collection.js +111 -65
- package/lib/core/auth/gssapi.js +132 -72
- package/lib/core/auth/x509.js +1 -1
- package/lib/core/connection/connect.js +1 -1
- package/lib/core/connection/connection.js +3 -4
- package/lib/core/connection/pool.js +3 -3
- package/lib/core/cursor.js +22 -12
- package/lib/core/sdam/monitor.js +14 -11
- package/lib/core/sdam/topology.js +2 -1
- package/lib/core/sdam/topology_description.js +1 -0
- package/lib/core/sessions.js +29 -35
- package/lib/core/topologies/mongos.js +2 -1
- package/lib/core/topologies/replset.js +14 -8
- package/lib/core/topologies/server.js +5 -4
- package/lib/core/uri_parser.js +9 -2
- package/lib/core/wireprotocol/query.js +12 -11
- package/lib/core/wireprotocol/write_command.js +10 -1
- package/lib/cursor.js +15 -13
- package/lib/db.js +44 -28
- package/lib/explain.js +55 -0
- package/lib/gridfs/grid_store.js +14 -9
- package/lib/gridfs-stream/upload.js +5 -3
- package/lib/mongo_client.js +14 -11
- package/lib/operations/add_user.js +3 -1
- package/lib/operations/admin_ops.js +1 -1
- package/lib/operations/aggregate.js +5 -7
- package/lib/operations/command_v2.js +13 -2
- package/lib/operations/common_functions.js +14 -27
- package/lib/operations/connect.js +32 -9
- package/lib/operations/create_indexes.js +24 -4
- package/lib/operations/delete_many.js +15 -2
- package/lib/operations/delete_one.js +15 -2
- package/lib/operations/distinct.js +10 -2
- package/lib/operations/find.js +7 -1
- package/lib/operations/find_and_modify.js +14 -1
- package/lib/operations/find_one.js +4 -0
- package/lib/operations/map_reduce.js +20 -1
- package/lib/operations/operation.js +11 -1
- package/lib/operations/update_many.js +23 -2
- package/lib/operations/update_one.js +22 -16
- package/lib/operations/validate_collection.js +1 -1
- package/lib/topologies/mongos.js +1 -1
- package/lib/topologies/server.js +1 -1
- package/lib/url_parser.js +19 -14
- package/lib/utils.js +39 -7
- package/lib/write_concern.js +18 -4
- package/package.json +35 -9
package/lib/url_parser.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const ReadPreference = require('./core').ReadPreference
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const ReadPreference = require('./core').ReadPreference;
|
|
4
|
+
const parser = require('url');
|
|
5
|
+
const f = require('util').format;
|
|
6
|
+
const Logger = require('./core').Logger;
|
|
7
|
+
const dns = require('dns');
|
|
8
8
|
const ReadConcern = require('./read_concern');
|
|
9
|
+
const qs = require('querystring');
|
|
10
|
+
const MongoParseError = require('./core/error').MongoParseError;
|
|
9
11
|
|
|
10
12
|
module.exports = function(url, options, callback) {
|
|
11
13
|
if (typeof options === 'function') (callback = options), (options = {});
|
|
@@ -87,23 +89,26 @@ module.exports = function(url, options, callback) {
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
dns.resolveTxt(result.host, function(err, record) {
|
|
90
|
-
if (err && err.code !== 'ENODATA') return callback(err);
|
|
92
|
+
if (err && err.code !== 'ENODATA' && err.code !== 'ENOTFOUND') return callback(err);
|
|
91
93
|
if (err && err.code === 'ENODATA') record = null;
|
|
92
94
|
|
|
93
95
|
if (record) {
|
|
94
96
|
if (record.length > 1) {
|
|
95
|
-
return callback(new
|
|
97
|
+
return callback(new MongoParseError('Multiple text records not allowed'));
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
record = record[0];
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
record = record[0].join('');
|
|
101
|
+
const parsedRecord = qs.parse(record);
|
|
102
|
+
const items = Object.keys(parsedRecord);
|
|
103
|
+
if (items.some(item => item !== 'authSource' && item !== 'replicaSet')) {
|
|
104
|
+
return callback(
|
|
105
|
+
new MongoParseError('Text record must only set `authSource` or `replicaSet`')
|
|
106
|
+
);
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
if (items.length > 0) {
|
|
110
|
+
connectionStringOptions.push(record);
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
// Add any options to the connection string
|
package/lib/utils.js
CHANGED
|
@@ -518,6 +518,22 @@ function decorateWithReadConcern(command, coll, options) {
|
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
+
/**
|
|
522
|
+
* Applies an explain to a given command.
|
|
523
|
+
* @internal
|
|
524
|
+
*
|
|
525
|
+
* @param {object} command - the command on which to apply the explain
|
|
526
|
+
* @param {Explain} explain - the options containing the explain verbosity
|
|
527
|
+
* @return the new command
|
|
528
|
+
*/
|
|
529
|
+
function decorateWithExplain(command, explain) {
|
|
530
|
+
if (command.explain) {
|
|
531
|
+
return command;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return { explain: command, verbosity: explain.verbosity };
|
|
535
|
+
}
|
|
536
|
+
|
|
521
537
|
const emitProcessWarning = msg => process.emitWarning(msg, 'DeprecationWarning');
|
|
522
538
|
const emitConsoleWarning = msg => console.error(msg);
|
|
523
539
|
const emitDeprecationWarning = process.emitWarning ? emitProcessWarning : emitConsoleWarning;
|
|
@@ -565,7 +581,10 @@ function deprecateOptions(config, fn) {
|
|
|
565
581
|
}
|
|
566
582
|
|
|
567
583
|
config.deprecatedOptions.forEach(deprecatedOption => {
|
|
568
|
-
if (
|
|
584
|
+
if (
|
|
585
|
+
Object.prototype.hasOwnProperty.call(options, deprecatedOption) &&
|
|
586
|
+
!optionsWarned.has(deprecatedOption)
|
|
587
|
+
) {
|
|
569
588
|
optionsWarned.add(deprecatedOption);
|
|
570
589
|
const msg = msgHandler(config.name, deprecatedOption);
|
|
571
590
|
emitDeprecationWarning(msg);
|
|
@@ -713,12 +732,13 @@ function makeInterruptableAsyncInterval(fn, options) {
|
|
|
713
732
|
const interval = options.interval || 1000;
|
|
714
733
|
const minInterval = options.minInterval || 500;
|
|
715
734
|
const immediate = typeof options.immediate === 'boolean' ? options.immediate : false;
|
|
735
|
+
const clock = typeof options.clock === 'function' ? options.clock : now;
|
|
716
736
|
|
|
717
737
|
function wake() {
|
|
718
|
-
const currentTime =
|
|
738
|
+
const currentTime = clock();
|
|
719
739
|
const timeSinceLastWake = currentTime - lastWakeTime;
|
|
720
740
|
const timeSinceLastCall = currentTime - lastCallTime;
|
|
721
|
-
const timeUntilNextCall =
|
|
741
|
+
const timeUntilNextCall = interval - timeSinceLastCall;
|
|
722
742
|
lastWakeTime = currentTime;
|
|
723
743
|
|
|
724
744
|
// For the streaming protocol: there is nothing obviously stopping this
|
|
@@ -737,6 +757,14 @@ function makeInterruptableAsyncInterval(fn, options) {
|
|
|
737
757
|
if (timeUntilNextCall > minInterval) {
|
|
738
758
|
reschedule(minInterval);
|
|
739
759
|
}
|
|
760
|
+
|
|
761
|
+
// This is possible in virtualized environments like AWS Lambda where our
|
|
762
|
+
// clock is unreliable. In these cases the timer is "running" but never
|
|
763
|
+
// actually completes, so we want to execute immediately and then attempt
|
|
764
|
+
// to reschedule.
|
|
765
|
+
if (timeUntilNextCall < 0) {
|
|
766
|
+
executeAndReschedule();
|
|
767
|
+
}
|
|
740
768
|
}
|
|
741
769
|
|
|
742
770
|
function stop() {
|
|
@@ -758,7 +786,7 @@ function makeInterruptableAsyncInterval(fn, options) {
|
|
|
758
786
|
|
|
759
787
|
function executeAndReschedule() {
|
|
760
788
|
lastWakeTime = 0;
|
|
761
|
-
lastCallTime =
|
|
789
|
+
lastCallTime = clock();
|
|
762
790
|
|
|
763
791
|
fn(err => {
|
|
764
792
|
if (err) throw err;
|
|
@@ -769,7 +797,7 @@ function makeInterruptableAsyncInterval(fn, options) {
|
|
|
769
797
|
if (immediate) {
|
|
770
798
|
executeAndReschedule();
|
|
771
799
|
} else {
|
|
772
|
-
lastCallTime =
|
|
800
|
+
lastCallTime = clock();
|
|
773
801
|
reschedule();
|
|
774
802
|
}
|
|
775
803
|
|
|
@@ -781,8 +809,11 @@ function hasAtomicOperators(doc) {
|
|
|
781
809
|
return doc.reduce((err, u) => err || hasAtomicOperators(u), null);
|
|
782
810
|
}
|
|
783
811
|
|
|
784
|
-
|
|
785
|
-
|
|
812
|
+
return (
|
|
813
|
+
Object.keys(typeof doc.toBSON !== 'function' ? doc : doc.toBSON())
|
|
814
|
+
.map(k => k[0])
|
|
815
|
+
.indexOf('$') >= 0
|
|
816
|
+
);
|
|
786
817
|
}
|
|
787
818
|
|
|
788
819
|
module.exports = {
|
|
@@ -808,6 +839,7 @@ module.exports = {
|
|
|
808
839
|
isPromiseLike,
|
|
809
840
|
decorateWithCollation,
|
|
810
841
|
decorateWithReadConcern,
|
|
842
|
+
decorateWithExplain,
|
|
811
843
|
deprecateOptions,
|
|
812
844
|
SUPPORTS,
|
|
813
845
|
MongoDBNamespace,
|
package/lib/write_concern.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const kWriteConcernKeys = new Set(['w', 'wtimeout', 'j', 'fsync']);
|
|
3
|
+
const kWriteConcernKeys = new Set(['w', 'wtimeout', 'j', 'journal', 'fsync']);
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The **WriteConcern** class is a class that represents a MongoDB WriteConcern.
|
|
@@ -37,7 +37,12 @@ class WriteConcern {
|
|
|
37
37
|
/**
|
|
38
38
|
* Construct a WriteConcern given an options object.
|
|
39
39
|
*
|
|
40
|
-
* @param {object} options The options object from which to extract the write concern.
|
|
40
|
+
* @param {object} [options] The options object from which to extract the write concern.
|
|
41
|
+
* @param {(number|string)} [options.w] **Deprecated** Use `options.writeConcern` instead
|
|
42
|
+
* @param {number} [options.wtimeout] **Deprecated** Use `options.writeConcern` instead
|
|
43
|
+
* @param {boolean} [options.j] **Deprecated** Use `options.writeConcern` instead
|
|
44
|
+
* @param {boolean} [options.fsync] **Deprecated** Use `options.writeConcern` instead
|
|
45
|
+
* @param {object|WriteConcern} [options.writeConcern] Specify write concern settings.
|
|
41
46
|
* @return {WriteConcern}
|
|
42
47
|
*/
|
|
43
48
|
static fromOptions(options) {
|
|
@@ -47,6 +52,7 @@ class WriteConcern {
|
|
|
47
52
|
options.w == null &&
|
|
48
53
|
options.wtimeout == null &&
|
|
49
54
|
options.j == null &&
|
|
55
|
+
options.journal == null &&
|
|
50
56
|
options.fsync == null)
|
|
51
57
|
) {
|
|
52
58
|
return;
|
|
@@ -64,12 +70,20 @@ class WriteConcern {
|
|
|
64
70
|
return new WriteConcern(
|
|
65
71
|
options.writeConcern.w,
|
|
66
72
|
options.writeConcern.wtimeout,
|
|
67
|
-
options.writeConcern.j,
|
|
73
|
+
options.writeConcern.j || options.writeConcern.journal,
|
|
68
74
|
options.writeConcern.fsync
|
|
69
75
|
);
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
console.warn(
|
|
79
|
+
`Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.`
|
|
80
|
+
);
|
|
81
|
+
return new WriteConcern(
|
|
82
|
+
options.w,
|
|
83
|
+
options.wtimeout,
|
|
84
|
+
options.j || options.journal,
|
|
85
|
+
options.fsync
|
|
86
|
+
);
|
|
73
87
|
}
|
|
74
88
|
}
|
|
75
89
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.4",
|
|
4
4
|
"description": "The official MongoDB driver for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,8 +23,28 @@
|
|
|
23
23
|
"snappy": "^6.3.4",
|
|
24
24
|
"bson-ext": "^2.0.0"
|
|
25
25
|
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"kerberos": {
|
|
28
|
+
"optional": true
|
|
29
|
+
},
|
|
30
|
+
"mongodb-client-encryption": {
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
"mongodb-extjson": {
|
|
34
|
+
"optional": true
|
|
35
|
+
},
|
|
36
|
+
"snappy": {
|
|
37
|
+
"optional": true
|
|
38
|
+
},
|
|
39
|
+
"bson-ext": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
42
|
+
"aws4": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
26
46
|
"dependencies": {
|
|
27
|
-
"bl": "^2.2.
|
|
47
|
+
"bl": "^2.2.1",
|
|
28
48
|
"bson": "^1.1.4",
|
|
29
49
|
"denque": "^1.4.1",
|
|
30
50
|
"require_optional": "^1.0.1",
|
|
@@ -36,8 +56,10 @@
|
|
|
36
56
|
"chalk": "^2.4.2",
|
|
37
57
|
"co": "4.6.0",
|
|
38
58
|
"coveralls": "^2.11.6",
|
|
39
|
-
"eslint": "^
|
|
40
|
-
"eslint-
|
|
59
|
+
"eslint": "^7.10.0",
|
|
60
|
+
"eslint-config-prettier": "^6.11.0",
|
|
61
|
+
"eslint-plugin-es": "^3.0.1",
|
|
62
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
41
63
|
"istanbul": "^0.4.5",
|
|
42
64
|
"jsdoc": "3.5.5",
|
|
43
65
|
"lodash.camelcase": "^4.3.0",
|
|
@@ -50,7 +72,8 @@
|
|
|
50
72
|
"sinon": "^4.3.0",
|
|
51
73
|
"sinon-chai": "^3.2.0",
|
|
52
74
|
"snappy": "^6.3.4",
|
|
53
|
-
"
|
|
75
|
+
"spec-xunit-file": "0.0.1-3",
|
|
76
|
+
"standard-version": "^8.0.2",
|
|
54
77
|
"util.promisify": "^1.0.1",
|
|
55
78
|
"worker-farm": "^1.5.0",
|
|
56
79
|
"wtfnode": "^0.8.0",
|
|
@@ -65,11 +88,14 @@
|
|
|
65
88
|
},
|
|
66
89
|
"scripts": {
|
|
67
90
|
"atlas": "mocha --opts '{}' ./test/manual/atlas_connectivity.test.js",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
91
|
+
"check:kerberos": "mocha --opts '{}' -t 60000 test/manual/kerberos.test.js",
|
|
92
|
+
"check:ldap": "mocha --opts '{}' test/manual/ldap.test.js",
|
|
93
|
+
"check:tls": "mocha --opts '{}' test/manual/tls_support.test.js",
|
|
94
|
+
"test": "npm run lint && mocha --recursive test/functional test/unit",
|
|
95
|
+
"test-nolint": "mocha --recursive test/functional test/unit",
|
|
96
|
+
"coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/unit test/functional",
|
|
71
97
|
"lint": "eslint -v && eslint lib test",
|
|
72
|
-
"format": "
|
|
98
|
+
"format": "npm run lint -- --fix",
|
|
73
99
|
"bench": "node test/benchmarks/driverBench/",
|
|
74
100
|
"generate-evergreen": "node .evergreen/generate_evergreen_tasks.js",
|
|
75
101
|
"release": "standard-version -i HISTORY.md"
|