Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
exports.BSONPure = require('bson').BSONPure;
exports.BSONNative = require('bson').BSONNative;
} catch(err) {
// do nothing
}
// export the driver version
exports.version = require('../../package').version;
[ 'commands/base_command'
, 'admin'
, 'collection'
, 'connection/read_preference'
, 'connection/connection'
, 'connection/server'
, 'connection/mongos'
, 'connection/repl_set/repl_set'
, 'mongo_client'
try {
exports.BSONPure = require('bson').BSONPure;
exports.BSONNative = require('bson').BSONNative;
} catch(err) {
// do nothing
}
[ 'commands/base_command'
, 'admin'
, 'collection'
, 'connection/read_preference'
, 'connection/connection'
, 'connection/server'
, 'connection/mongos'
, 'connection/repl_set'
, 'mongo_client'
, 'cursor'
, 'db'
, 'mongo_client'
// Allow slaveOk override
this.slaveOk = this.options['slave_ok'] == null ? false : this.options['slave_ok'];
this.slaveOk = this.options['slaveOk'] == null ? this.slaveOk : this.options['slaveOk'];
// Number of operations to buffer before failure
this.bufferMaxEntries = typeof this.options['bufferMaxEntries'] == 'number' ? this.options['bufferMaxEntries'] : -1;
// Ensure we have a valid db name
validateDatabaseName(databaseName);
// Contains all the connections for the db
try {
this.native_parser = this.options.native_parser;
// The bson lib
var bsonLib = this.bsonLib = this.options.native_parser ? require('bson').BSONNative : require('bson').BSONPure;
bsonLib = require('bson').BSONPure;
// Fetch the serializer object
var BSON = bsonLib.BSON;
// Create a new instance
this.bson = new BSON([bsonLib.Long, bsonLib.ObjectID, bsonLib.Binary, bsonLib.Code, bsonLib.DBRef, bsonLib.Symbol, bsonLib.Double, bsonLib.Timestamp, bsonLib.MaxKey, bsonLib.MinKey]);
this.bson.promoteLongs = this.options.promoteLongs == null ? true : this.options.promoteLongs;
// Backward compatibility to access types
this.bson_deserializer = bsonLib;
this.bson_serializer = bsonLib;
// Add any overrides to the serializer and deserializer
this.bson_deserializer.promoteLongs = this.options.promoteLongs == null ? true : this.options.promoteLongs;
} catch (err) {
// If we tried to instantiate the native driver
// Allow slaveOk override
this.slaveOk = this.options['slave_ok'] == null ? false : this.options['slave_ok'];
this.slaveOk = this.options['slaveOk'] == null ? this.slaveOk : this.options['slaveOk'];
// Number of operations to buffer before failure
this.bufferMaxEntries = typeof this.options['bufferMaxEntries'] == 'number' ? this.options['bufferMaxEntries'] : -1;
// Ensure we have a valid db name
validateDatabaseName(databaseName);
// Contains all the connections for the db
try {
this.native_parser = this.options.native_parser;
// The bson lib
var bsonLib = this.bsonLib = this.options.native_parser ? require('bson').BSONNative : require('bson').BSONPure;
bsonLib = require('bson').BSONPure;
// Fetch the serializer object
var BSON = bsonLib.BSON;
// Create a new instance
this.bson = new BSON([bsonLib.Long, bsonLib.ObjectID, bsonLib.Binary, bsonLib.Code, bsonLib.DBRef, bsonLib.Symbol, bsonLib.Double, bsonLib.Timestamp, bsonLib.MaxKey, bsonLib.MinKey]);
this.bson.promoteLongs = this.options.promoteLongs == null ? true : this.options.promoteLongs;
// Backward compatibility to access types
this.bson_deserializer = bsonLib;
this.bson_serializer = bsonLib;
// Add any overrides to the serializer and deserializer
this.bson_deserializer.promoteLongs = this.options.promoteLongs == null ? true : this.options.promoteLongs;
} catch (err) {
// If we tried to instantiate the native driver
// Verify that nobody is using this config
if(!overrideUsedFlag && this.serverConfig != null && typeof this.serverConfig == 'object' && this.serverConfig._isUsed && this.serverConfig._isUsed()) {
throw new Error("A Server or ReplSet instance cannot be shared across multiple Db instances");
} else if(!overrideUsedFlag && typeof this.serverConfig == 'object'){
// Set being used
this.serverConfig._used = true;
}
// Ensure we have a valid db name
validateDatabaseName(databaseName);
// Contains all the connections for the db
try {
this.native_parser = this.options.native_parser;
// The bson lib
var bsonLib = this.bsonLib = this.options.native_parser ? require('bson').BSONNative : require('bson').BSONPure;
// Fetch the serializer object
var BSON = bsonLib.BSON;
// Create a new instance
this.bson = new BSON([bsonLib.Long, bsonLib.ObjectID, bsonLib.Binary, bsonLib.Code, bsonLib.DBRef, bsonLib.Symbol, bsonLib.Double, bsonLib.Timestamp, bsonLib.MaxKey, bsonLib.MinKey]);
// Backward compatibility to access types
this.bson_deserializer = bsonLib;
this.bson_serializer = bsonLib;
} catch (err) {
// If we tried to instantiate the native driver
var msg = "Native bson parser not compiled, please compile "
+ "or avoid using native_parser=true";
throw Error(msg);
}
// Internal state of the server
this._state = 'disconnected';
var _setNativeParser = function(db_options) {
if(typeof db_options.native_parser == 'boolean') return db_options.native_parser;
try {
require('bson').BSONNative.BSON;
return true;
} catch(err) {
return false;
}
}
var _setNativeParser = function(db_options) {
if(typeof db_options.native_parser == 'boolean') return db_options.native_parser;
try {
require('bson').BSONNative.BSON;
return true;
} catch(err) {
return false;
}
}
var _setNativeParser = function(db_options) {
if(typeof db_options.native_parser == 'boolean') return db_options.native_parser;
try {
require('bson').BSONNative.BSON;
return true;
} catch(err) {
return false;
}
}