How to use the bson.BSONNative function in bson

To help you get started, we’ve selected a few bson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Hanul / UPPERCASE / UPPERCASE-DB / node_modules / mongodb / lib / mongodb / index.js View on Github external
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'
github hyperstudio / MIT-Annotation-Data-Store / node_modules / mongoose / node_modules / mongodb / lib / mongodb / index.js View on Github external
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'
github skepticfx / domstorm / node_modules / mongoose / node_modules / mongodb / lib / mongodb / db.js View on Github external
// 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
github linxixuan / linxixuan-blog / node_modules / mongoose / node_modules / mongodb / lib / mongodb / db.js View on Github external
// 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
github RTimal / DrawingBoard / node_modules / mongoose / node_modules / mongodb / lib / mongodb / db.js View on Github external
// 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';
github webuildsg / webuild / node_modules / mongoose / node_modules / mongodb / lib / mongodb / db.js View on Github external
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;
  }
}
github Hanul / UPPERCASE / UPPERCASE-DB / node_modules / mongodb / lib / mongodb / mongo_client.js View on Github external
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;
  }
}
github KIDx / GzhuOJ / node_modules / mongodb / lib / mongodb / mongo_client.js View on Github external
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;
  }
}