aboutsummaryrefslogtreecommitdiff
path: root/node_modules/mongodb/lib/mongo_client.js
diff options
context:
space:
mode:
authornanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-08-14 10:13:55 +0000
committernanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-08-14 10:13:55 +0000
commita532390f81e35f611fd02ad3d543f4d52217ca3c (patch)
tree7bebb4f5614afb82c3103b6e9730a62f0b97a42d /node_modules/mongodb/lib/mongo_client.js
parentef2674cfe13d2c425c5a3b312244c46f2531979d (diff)
Fixed signin and signup
Diffstat (limited to 'node_modules/mongodb/lib/mongo_client.js')
-rw-r--r--node_modules/mongodb/lib/mongo_client.js41
1 files changed, 32 insertions, 9 deletions
diff --git a/node_modules/mongodb/lib/mongo_client.js b/node_modules/mongodb/lib/mongo_client.js
index 8017604..6de464d 100644
--- a/node_modules/mongodb/lib/mongo_client.js
+++ b/node_modules/mongodb/lib/mongo_client.js
@@ -7,9 +7,10 @@ var parse = require('./url_parser')
, Define = require('./metadata')
, ReadPreference = require('./read_preference')
, Logger = require('mongodb-core').Logger
+ , MongoError = require('mongodb-core').MongoError
, Db = require('./db')
, dns = require('dns')
- , f = require('util').format
+ , f = require('util').format
, shallowClone = require('./utils').shallowClone;
/**
@@ -130,9 +131,12 @@ var mergeOptions = function(target, source, flatten) {
var createUnifiedOptions = function(finalOptions, options) {
var childOptions = ['mongos', 'server', 'db'
, 'replset', 'db_options', 'server_options', 'rs_options', 'mongos_options'];
+ var noMerge = ['collation'];
for(var name in options) {
- if(childOptions.indexOf(name.toLowerCase()) != -1) {
+ if(noMerge.indexOf(name.toLowerCase()) != -1) {
+ finalOptions[name] = options[name];
+ } else if(childOptions.indexOf(name.toLowerCase()) != -1) {
finalOptions = mergeOptions(finalOptions, options[name], false);
} else {
if(options[name] && typeof options[name] == 'object' && !Buffer.isBuffer(options[name]) && !Array.isArray(options[name])) {
@@ -157,9 +161,14 @@ function translateOptions(options) {
options.readPreference.tags = options.readPreferenceTags || options.read_preference_tags;
}
+ // Do we have maxStalenessMS
+ if(options.maxStalenessMS) {
+ options.readPreference.maxStalenessMS = options.maxStalenessMS;
+ }
+
// Set the socket and connection timeouts
- if(!options.socketTimeoutMS) options.socketTimeoutMS = 30000;
- if(!options.connectTimeoutMS) options.connectTimeoutMS = 30000;
+ if(!options.socketTimeoutMS == null) options.socketTimeoutMS = 30000;
+ if(!options.connectTimeoutMS == null) options.connectTimeoutMS = 30000;
// Create server instances
return options.servers.map(function(serverObj) {
@@ -269,21 +278,35 @@ var connect = function(url, options, callback) {
_finalOptions = createUnifiedOptions(_finalOptions, options);
// Check if we have connection and socket timeout set
- if(!_finalOptions.socketTimeoutMS) _finalOptions.socketTimeoutMS = 120000;
- if(!_finalOptions.connectTimeoutMS) _finalOptions.connectTimeoutMS = 120000;
+ if(!_finalOptions.socketTimeoutMS == null) _finalOptions.socketTimeoutMS = 120000;
+ if(!_finalOptions.connectTimeoutMS == null) _finalOptions.connectTimeoutMS = 120000;
// Failure modes
if(object.servers.length == 0) {
throw new Error("connection string must contain at least one seed host");
}
+ function connectCallback(err, db) {
+ if(err && err.message == 'no mongos proxies found in seed list') {
+ if(logger.isWarn()) {
+ logger.warn(f('seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name'));
+ }
+
+ // Return a more specific error message for MongoClient.connect
+ return callback(new MongoError('seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name'));
+ }
+
+ // Return the error and db instance
+ callback(err, db);
+ }
+
// Do we have a replicaset then skip discovery and go straight to connectivity
if(_finalOptions.replicaSet || _finalOptions.rs_name) {
- return createReplicaset(_finalOptions, connectHandler(_finalOptions, callback));
+ return createReplicaset(_finalOptions, connectHandler(_finalOptions, connectCallback));
} else if(object.servers.length > 1) {
- return createMongos(_finalOptions, connectHandler(_finalOptions, callback));
+ return createMongos(_finalOptions, connectHandler(_finalOptions, connectCallback));
} else {
- return createServer(_finalOptions, connectHandler(_finalOptions, callback));
+ return createServer(_finalOptions, connectHandler(_finalOptions, connectCallback));
}
}