mongodb 2.2.20 → 2.2.24
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 +32 -3
- package/conf.json +4 -1
- package/lib/apm.js +2 -2
- package/lib/db.js +8 -5
- package/lib/mongo_client.js +124 -12
- package/lib/mongos.js +11 -1
- package/lib/replset.js +14 -2
- package/package.json +3 -3
package/HISTORY.md
CHANGED
|
@@ -1,14 +1,43 @@
|
|
|
1
|
+
2.2.24 2017-02-14
|
|
2
|
+
-----------------
|
|
3
|
+
* NODE-935, NODE-931 Make MongoClient strict options validation optional and instead print annoying console.warn entries.
|
|
4
|
+
|
|
5
|
+
2.2.23 2017-02-13
|
|
6
|
+
-----------------
|
|
7
|
+
* Updated mongodb-core to 2.1.8.
|
|
8
|
+
* NODE-925 ensure we reschedule operations while pool is < poolSize while pool is growing and there are no connections with not currently performing work.
|
|
9
|
+
* NODE-927 fixes issue where authentication was performed against arbiter instances.
|
|
10
|
+
* NODE-915 Normalize all host names to avoid comparison issues.
|
|
11
|
+
* Fixed issue where pool.destroy would never finish due to a single operation not being executed and keeping it open.
|
|
12
|
+
* NODE-931 Validates all the options for MongoClient.connect and fixes missing connection settings.
|
|
13
|
+
* NODE-929 Update SSL tutorial to correctly reflect the non-need for server/mongos/replset subobjects
|
|
14
|
+
* Fix sensitive command check (Issue #1473, https://github.com/Annoraaq)
|
|
15
|
+
|
|
16
|
+
2.2.22 2017-01-24
|
|
17
|
+
-----------------
|
|
18
|
+
* Updated mongodb-core to 2.1.7.
|
|
19
|
+
* NODE-919 ReplicaSet connection does not close immediately (Issue #156).
|
|
20
|
+
* NODE-901 Fixed bug when normalizing host names.
|
|
21
|
+
* NODE-909 Fixed readPreference issue caused by direct connection to primary.
|
|
22
|
+
* NODE-910 Fixed issue when bufferMaxEntries == 0 and read preference set to nearest.
|
|
23
|
+
* Add missing unref implementations for replset, mongos (Issue #1455, https://github.com/zbjornson)
|
|
24
|
+
|
|
25
|
+
2.2.21 2017-01-13
|
|
26
|
+
-----------------
|
|
27
|
+
* Updated mongodb-core to 2.1.6.
|
|
28
|
+
* NODE-908 Keep auth contexts in replset and mongos topology to ensure correct application of authentication credentials when primary is first server to be detected causing an immediate connect event to happen.
|
|
29
|
+
|
|
1
30
|
2.2.20 2017-01-11
|
|
2
31
|
-----------------
|
|
3
|
-
|
|
32
|
+
* Updated mongodb-core to 2.1.5 to include bson 1.0.4 and bson-ext 1.0.4 due to Buffer.from being broken in early node 4.x versions.
|
|
4
33
|
|
|
5
34
|
2.2.19 2017-01-03
|
|
6
35
|
-----------------
|
|
7
|
-
|
|
36
|
+
* Corrupted Npm release fix.
|
|
8
37
|
|
|
9
38
|
2.2.18 2017-01-03
|
|
10
39
|
-----------------
|
|
11
|
-
|
|
40
|
+
* Updated mongodb-core to 2.1.4 to fix bson ObjectId toString issue with utils.inspect messing with toString parameters in node 6.
|
|
12
41
|
|
|
13
42
|
2.2.17 2017-01-02
|
|
14
43
|
-----------------
|
package/conf.json
CHANGED
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
"node_modules/bson/lib/bson/symbol.js",
|
|
37
37
|
"node_modules/bson/lib/bson/timestamp.js",
|
|
38
38
|
"node_modules/bson/lib/bson/max_key.js",
|
|
39
|
-
"node_modules/bson/lib/bson/min_key.js"
|
|
39
|
+
"node_modules/bson/lib/bson/min_key.js",
|
|
40
|
+
"node_modules/bson/lib/bson/decimal128.js",
|
|
41
|
+
"node_modules/bson/lib/bson/int_32.js",
|
|
42
|
+
"node_modules/bson/lib/bson/regexp.js"
|
|
40
43
|
]
|
|
41
44
|
},
|
|
42
45
|
"templates": {
|
package/lib/apm.js
CHANGED
|
@@ -181,7 +181,7 @@ var Instrumentation = function(core, options, callback) {
|
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
// Filter out any sensitive commands
|
|
184
|
-
if(senstiveCommands.indexOf(commandName.toLowerCase())) {
|
|
184
|
+
if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) {
|
|
185
185
|
command.commandObj = {};
|
|
186
186
|
command.commandObj[commandName] = true;
|
|
187
187
|
}
|
|
@@ -208,7 +208,7 @@ var Instrumentation = function(core, options, callback) {
|
|
|
208
208
|
command.failure = err || r.result.writeErrors || r.result;
|
|
209
209
|
|
|
210
210
|
// Filter out any sensitive commands
|
|
211
|
-
if(senstiveCommands.indexOf(commandName.toLowerCase())) {
|
|
211
|
+
if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) {
|
|
212
212
|
command.failure = {};
|
|
213
213
|
}
|
|
214
214
|
|
package/lib/db.js
CHANGED
|
@@ -1032,8 +1032,6 @@ Db.prototype.createIndex = function(name, fieldOrSpec, options, callback) {
|
|
|
1032
1032
|
options = options == null ? {} : options;
|
|
1033
1033
|
// Shallow clone the options
|
|
1034
1034
|
options = shallowClone(options);
|
|
1035
|
-
// Run only against primary
|
|
1036
|
-
options.readPreference = ReadPreference.PRIMARY;
|
|
1037
1035
|
|
|
1038
1036
|
// If we have a callback fallback
|
|
1039
1037
|
if(typeof callback == 'function') return createIndex(self, name, fieldOrSpec, options, callback);
|
|
@@ -1048,12 +1046,15 @@ Db.prototype.createIndex = function(name, fieldOrSpec, options, callback) {
|
|
|
1048
1046
|
|
|
1049
1047
|
var createIndex = function(self, name, fieldOrSpec, options, callback) {
|
|
1050
1048
|
// Get the write concern options
|
|
1051
|
-
var finalOptions = writeConcern({}, self, options);
|
|
1049
|
+
var finalOptions = writeConcern({}, self, options, { readPreference: ReadPreference.PRIMARY });
|
|
1052
1050
|
// Ensure we have a callback
|
|
1053
1051
|
if(finalOptions.writeConcern && typeof callback != 'function') {
|
|
1054
1052
|
throw MongoError.create({message: "Cannot use a writeConcern without a provided callback", driver:true});
|
|
1055
1053
|
}
|
|
1056
1054
|
|
|
1055
|
+
// Run only against primary
|
|
1056
|
+
options.readPreference = ReadPreference.PRIMARY;
|
|
1057
|
+
|
|
1057
1058
|
// Did the user destroy the topology
|
|
1058
1059
|
if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed'));
|
|
1059
1060
|
|
|
@@ -1136,6 +1137,9 @@ var ensureIndex = function(self, name, fieldOrSpec, options, callback) {
|
|
|
1136
1137
|
// Did the user destroy the topology
|
|
1137
1138
|
if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed'));
|
|
1138
1139
|
|
|
1140
|
+
// Merge primary readPreference
|
|
1141
|
+
finalOptions.readPreference = ReadPreference.PRIMARY
|
|
1142
|
+
|
|
1139
1143
|
// Check if the index allready exists
|
|
1140
1144
|
self.indexInformation(name, finalOptions, function(err, indexInformation) {
|
|
1141
1145
|
if(err != null && err.code != 26) return handleCallback(callback, err, null);
|
|
@@ -1645,7 +1649,6 @@ var indexInformation = function(self, name, options, callback) {
|
|
|
1645
1649
|
|
|
1646
1650
|
// Did the user destroy the topology
|
|
1647
1651
|
if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed'));
|
|
1648
|
-
|
|
1649
1652
|
// Process all the results from the index command and collection
|
|
1650
1653
|
var processResults = function(indexes) {
|
|
1651
1654
|
// Contains all the information
|
|
@@ -1664,7 +1667,7 @@ var indexInformation = function(self, name, options, callback) {
|
|
|
1664
1667
|
}
|
|
1665
1668
|
|
|
1666
1669
|
// Get the list of indexes of the specified collection
|
|
1667
|
-
self.collection(name).listIndexes().toArray(function(err, indexes) {
|
|
1670
|
+
self.collection(name).listIndexes(options).toArray(function(err, indexes) {
|
|
1668
1671
|
if(err) return callback(toError(err));
|
|
1669
1672
|
if(!Array.isArray(indexes)) return handleCallback(callback, null, []);
|
|
1670
1673
|
if(full) return handleCallback(callback, null, indexes);
|
package/lib/mongo_client.js
CHANGED
|
@@ -26,6 +26,38 @@ var parse = require('./url_parser')
|
|
|
26
26
|
* db.close();
|
|
27
27
|
* });
|
|
28
28
|
*/
|
|
29
|
+
var validOptionNames = ['poolSize', 'ssl', 'sslValidate', 'sslCA', 'sslCert',
|
|
30
|
+
'sslKey', 'sslPass', 'autoReconnect', 'noDelay', 'keepAlive', 'connectTimeoutMS',
|
|
31
|
+
'socketTimeoutMS', 'reconnectTries', 'reconnectInterval', 'ha', 'haInterval',
|
|
32
|
+
'replicaSet', 'secondaryAcceptableLatencyMS', 'acceptableLatencyMS',
|
|
33
|
+
'connectWithNoPrimary', 'authSource', 'w', 'wtimeout', 'j', 'forceServerObjectId',
|
|
34
|
+
'serializeFunctions', 'ignoreUndefined', 'raw', 'promoteLongs', 'bufferMaxEntries',
|
|
35
|
+
'readPreference', 'pkFactory', 'promiseLibrary', 'readConcern', 'maxStalenessSeconds',
|
|
36
|
+
'loggerLevel', 'logger', 'promoteValues', 'promoteBuffers', 'promoteLongs',
|
|
37
|
+
'domainsEnabled', 'keepAliveInitialDelay', 'checkServerIdentity', 'validateOptions'];
|
|
38
|
+
var ignoreOptionNames = ['native_parser'];
|
|
39
|
+
var legacyOptionNames = ['server', 'replset', 'replSet', 'mongos', 'db'];
|
|
40
|
+
|
|
41
|
+
function validOptions(options) {
|
|
42
|
+
var _validOptions = validOptionNames.concat(legacyOptionNames);
|
|
43
|
+
|
|
44
|
+
for(var name in options) {
|
|
45
|
+
if(ignoreOptionNames.indexOf(name) != -1) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if(_validOptions.indexOf(name) == -1 && options.validateOptions) {
|
|
50
|
+
return new MongoError(f('option %s is not supported', name));
|
|
51
|
+
} else if(_validOptions.indexOf(name) == -1) {
|
|
52
|
+
console.warn(f('the options [%s] is not supported', name));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if(legacyOptionNames.indexOf(name) != -1) {
|
|
56
|
+
console.warn(f('the server/replset/mongos options are deprecated, '
|
|
57
|
+
+ 'all their options are supported at the top level of the options object [%s]', validOptionNames));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
29
61
|
|
|
30
62
|
/**
|
|
31
63
|
* Creates a new MongoClient instance
|
|
@@ -49,13 +81,49 @@ function MongoClient() {
|
|
|
49
81
|
*
|
|
50
82
|
* @method
|
|
51
83
|
* @param {string} url The connection URI string
|
|
52
|
-
* @param {object} [options
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
56
|
-
* @param {
|
|
57
|
-
* @param {
|
|
84
|
+
* @param {object} [options] Optional settings.
|
|
85
|
+
* @param {number} [options.poolSize=5] poolSize The maximum size of the individual server pool.
|
|
86
|
+
* @param {boolean} [options.ssl=false] Enable SSL connection.
|
|
87
|
+
* @param {Buffer} [options.sslCA=undefined] SSL Certificate store binary buffer
|
|
88
|
+
* @param {Buffer} [options.sslCert=undefined] SSL Certificate binary buffer
|
|
89
|
+
* @param {Buffer} [options.sslKey=undefined] SSL Key file binary buffer
|
|
90
|
+
* @param {string} [options.sslPass=undefined] SSL Certificate pass phrase
|
|
91
|
+
* @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.
|
|
92
|
+
* @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances
|
|
93
|
+
* @param {boolean} [options.noDelay=true] TCP Connection no delay
|
|
94
|
+
* @param {boolean} [options.keepAlive=0] The number of milliseconds to wait before initiating keepAlive on the TCP socket.
|
|
95
|
+
* @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting
|
|
96
|
+
* @param {number} [options.socketTimeoutMS=30000] TCP Socket timeout setting
|
|
97
|
+
* @param {number} [options.reconnectTries=30] Server attempt to reconnect #times
|
|
98
|
+
* @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries
|
|
99
|
+
* @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies.
|
|
100
|
+
* @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry
|
|
101
|
+
* @param {string} [options.replicaSet=undefined] The Replicaset set name
|
|
102
|
+
* @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection
|
|
103
|
+
* @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection.
|
|
104
|
+
* @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available
|
|
105
|
+
* @param {string} [options.authSource=undefined] Define the database to authenticate against
|
|
106
|
+
* @param {(number|string)} [options.w=null] The write concern.
|
|
107
|
+
* @param {number} [options.wtimeout=null] The write concern timeout.
|
|
108
|
+
* @param {boolean} [options.j=false] Specify a journal write concern.
|
|
109
|
+
* @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
|
|
110
|
+
* @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
|
|
111
|
+
* @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
|
|
112
|
+
* @param {boolean} [options.raw=false] Return document results as raw BSON buffers.
|
|
113
|
+
* @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution.
|
|
114
|
+
* @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
|
|
115
|
+
* @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types.
|
|
116
|
+
* @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited.
|
|
117
|
+
* @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
|
|
118
|
+
* @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
|
|
119
|
+
* @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys.
|
|
58
120
|
* @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
|
|
121
|
+
* @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
|
|
122
|
+
* @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)
|
|
123
|
+
* @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed);
|
|
124
|
+
* @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug)
|
|
125
|
+
* @param {object} [options.logger=undefined] Custom logger object
|
|
126
|
+
* @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness.
|
|
59
127
|
* @param {MongoClient~connectCallback} [callback] The command result callback
|
|
60
128
|
* @return {Promise} returns Promise if no callback passed
|
|
61
129
|
*/
|
|
@@ -74,13 +142,49 @@ var define = MongoClient.define = new Define('MongoClient', MongoClient, false);
|
|
|
74
142
|
* @method
|
|
75
143
|
* @static
|
|
76
144
|
* @param {string} url The connection URI string
|
|
77
|
-
* @param {object} [options
|
|
78
|
-
* @param {
|
|
79
|
-
* @param {
|
|
80
|
-
* @param {
|
|
81
|
-
* @param {
|
|
82
|
-
* @param {
|
|
145
|
+
* @param {object} [options] Optional settings.
|
|
146
|
+
* @param {number} [options.poolSize=5] poolSize The maximum size of the individual server pool.
|
|
147
|
+
* @param {boolean} [options.ssl=false] Enable SSL connection.
|
|
148
|
+
* @param {Buffer} [options.sslCA=undefined] SSL Certificate store binary buffer
|
|
149
|
+
* @param {Buffer} [options.sslCert=undefined] SSL Certificate binary buffer
|
|
150
|
+
* @param {Buffer} [options.sslKey=undefined] SSL Key file binary buffer
|
|
151
|
+
* @param {string} [options.sslPass=undefined] SSL Certificate pass phrase
|
|
152
|
+
* @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.
|
|
153
|
+
* @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances
|
|
154
|
+
* @param {boolean} [options.noDelay=true] TCP Connection no delay
|
|
155
|
+
* @param {boolean} [options.keepAlive=0] The number of milliseconds to wait before initiating keepAlive on the TCP socket.
|
|
156
|
+
* @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting
|
|
157
|
+
* @param {number} [options.socketTimeoutMS=30000] TCP Socket timeout setting
|
|
158
|
+
* @param {number} [options.reconnectTries=30] Server attempt to reconnect #times
|
|
159
|
+
* @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries
|
|
160
|
+
* @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies.
|
|
161
|
+
* @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry
|
|
162
|
+
* @param {string} [options.replicaSet=undefined] The Replicaset set name
|
|
163
|
+
* @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection
|
|
164
|
+
* @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection.
|
|
165
|
+
* @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available
|
|
166
|
+
* @param {string} [options.authSource=undefined] Define the database to authenticate against
|
|
167
|
+
* @param {(number|string)} [options.w=null] The write concern.
|
|
168
|
+
* @param {number} [options.wtimeout=null] The write concern timeout.
|
|
169
|
+
* @param {boolean} [options.j=false] Specify a journal write concern.
|
|
170
|
+
* @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
|
|
171
|
+
* @param {boolean} [options.serializeFunctions=false] Serialize functions on any object.
|
|
172
|
+
* @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields.
|
|
173
|
+
* @param {boolean} [options.raw=false] Return document results as raw BSON buffers.
|
|
174
|
+
* @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution.
|
|
175
|
+
* @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers.
|
|
176
|
+
* @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types.
|
|
177
|
+
* @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited.
|
|
178
|
+
* @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
|
|
179
|
+
* @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
|
|
180
|
+
* @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys.
|
|
83
181
|
* @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
|
|
182
|
+
* @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported)
|
|
183
|
+
* @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)
|
|
184
|
+
* @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed);
|
|
185
|
+
* @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug)
|
|
186
|
+
* @param {object} [options.logger=undefined] Custom logger object
|
|
187
|
+
* @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness.
|
|
84
188
|
* @param {MongoClient~connectCallback} [callback] The command result callback
|
|
85
189
|
* @return {Promise} returns Promise if no callback passed
|
|
86
190
|
*/
|
|
@@ -90,6 +194,9 @@ MongoClient.connect = function(url, options, callback) {
|
|
|
90
194
|
options = args.length ? args.shift() : null;
|
|
91
195
|
options = options || {};
|
|
92
196
|
|
|
197
|
+
// Validate options object
|
|
198
|
+
var err = validOptions(options);
|
|
199
|
+
|
|
93
200
|
// Get the promiseLibrary
|
|
94
201
|
var promiseLibrary = options.promiseLibrary;
|
|
95
202
|
|
|
@@ -102,6 +209,9 @@ MongoClient.connect = function(url, options, callback) {
|
|
|
102
209
|
// Return a promise
|
|
103
210
|
if(typeof callback != 'function') {
|
|
104
211
|
return new promiseLibrary(function(resolve, reject) {
|
|
212
|
+
// Did we have a validation error
|
|
213
|
+
if(err) return reject(err);
|
|
214
|
+
// Attempt to connect
|
|
105
215
|
connect(url, options, function(err, db) {
|
|
106
216
|
if(err) return reject(err);
|
|
107
217
|
resolve(db);
|
|
@@ -109,6 +219,8 @@ MongoClient.connect = function(url, options, callback) {
|
|
|
109
219
|
});
|
|
110
220
|
}
|
|
111
221
|
|
|
222
|
+
// Did we have a validation error
|
|
223
|
+
if(err) return callback(err);
|
|
112
224
|
// Fallback to callback based connect
|
|
113
225
|
connect(url, options, callback);
|
|
114
226
|
}
|
package/lib/mongos.js
CHANGED
|
@@ -397,8 +397,18 @@ Mongos.prototype.lastIsMaster = function() {
|
|
|
397
397
|
return this.s.mongos.lastIsMaster();
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Unref all sockets
|
|
402
|
+
* @method
|
|
403
|
+
*/
|
|
404
|
+
Mongos.prototype.unref = function () {
|
|
405
|
+
return this.s.mongos.unref();
|
|
406
|
+
}
|
|
407
|
+
|
|
400
408
|
Mongos.prototype.close = function(forceClosed) {
|
|
401
|
-
this.s.mongos.destroy(
|
|
409
|
+
this.s.mongos.destroy({
|
|
410
|
+
force: typeof forceClosed == 'boolean' ? forceClosed : false,
|
|
411
|
+
});
|
|
402
412
|
// We need to wash out all stored processes
|
|
403
413
|
if(forceClosed == true) {
|
|
404
414
|
this.s.storeOptions.force = forceClosed;
|
package/lib/replset.js
CHANGED
|
@@ -45,7 +45,7 @@ var legalOptionNames = ['ha', 'haInterval', 'replicaSet', 'rs_name', 'secondaryA
|
|
|
45
45
|
, 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
|
|
46
46
|
, 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS', 'strategy', 'debug'
|
|
47
47
|
, 'loggerLevel', 'logger', 'reconnectTries', 'appname', 'domainsEnabled'
|
|
48
|
-
, 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
|
|
48
|
+
, 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers', 'maxStalenessSeconds'];
|
|
49
49
|
|
|
50
50
|
// Get package.json variable
|
|
51
51
|
var driverVersion = require(__dirname + '/../package.json').version;
|
|
@@ -81,6 +81,7 @@ var release = os.release();
|
|
|
81
81
|
* @param {number} [options.socketOptions.connectTimeoutMS=10000] TCP Connection timeout setting
|
|
82
82
|
* @param {number} [options.socketOptions.socketTimeoutMS=0] TCP Socket timeout setting
|
|
83
83
|
* @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
|
|
84
|
+
* @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed);
|
|
84
85
|
* @fires ReplSet#connect
|
|
85
86
|
* @fires ReplSet#ha
|
|
86
87
|
* @fires ReplSet#joined
|
|
@@ -445,9 +446,20 @@ ReplSet.prototype.lastIsMaster = function() {
|
|
|
445
446
|
return this.s.replset.lastIsMaster();
|
|
446
447
|
}
|
|
447
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Unref all sockets
|
|
451
|
+
* @method
|
|
452
|
+
*/
|
|
453
|
+
ReplSet.prototype.unref = function() {
|
|
454
|
+
return this.s.replset.unref();
|
|
455
|
+
}
|
|
456
|
+
|
|
448
457
|
ReplSet.prototype.close = function(forceClosed) {
|
|
449
458
|
var self = this;
|
|
450
|
-
|
|
459
|
+
// Call destroy on the topology
|
|
460
|
+
this.s.replset.destroy({
|
|
461
|
+
force: typeof forceClosed == 'boolean' ? forceClosed : false,
|
|
462
|
+
});
|
|
451
463
|
// We need to wash out all stored processes
|
|
452
464
|
if(forceClosed == true) {
|
|
453
465
|
this.s.storeOptions.force = forceClosed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.24",
|
|
4
4
|
"description": "The official MongoDB driver for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"es6-promise": "3.2.1",
|
|
17
|
-
"mongodb-core": "2.1.
|
|
17
|
+
"mongodb-core": "2.1.8",
|
|
18
18
|
"readable-stream": "2.1.5"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"JSONStream": "^1.0.7",
|
|
22
22
|
"betterbenchmarks": "^0.1.0",
|
|
23
23
|
"bluebird": "3.4.6",
|
|
24
|
-
"bson": "
|
|
24
|
+
"bson": "latest",
|
|
25
25
|
"cli-table": "^0.3.1",
|
|
26
26
|
"co": "4.6.0",
|
|
27
27
|
"colors": "^1.1.2",
|