How to use the mongodb.BSONPure function in mongodb

To help you get started, we’ve selected a few mongodb 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 montagejs / screening / server / rest-api / batches.js View on Github external
/* 
 This file contains proprietary software owned by Motorola Mobility, Inc.<br>
 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br>
 (c) Copyright 2011 Motorola Mobility, Inc.  All Rights Reserved.
  */
var routingConfig = require("./routing-config.js"),
    BSON = require('mongodb').BSONPure,
    express = require("express");

module.exports = function(batchesProvider) {
    var app = express.createServer();

    app.mounted(function(otherApp) {
        console.info("[batches] express app was mounted.");
    });

    /**
     * GETs all the available batches
     */
    app.get("/", routingConfig.provides('json', '*/*'), function(req, res, next) {
        batchesProvider.findAll({sort: ["name", "asc"]}, function(error, batches) {
            if (error) return next(new Error(error));
github codeactual / mainevent / app / modules / mongodb.js View on Github external
/**
 * MongoDB storage implementation.
 */

'use strict';

var mongoDbLib = require('mongodb'),
    BSON = mongoDbLib.BSONPure,
    config = mainevent.getConfig().mongodb,
    EventEmitter = require('events').EventEmitter;

/**
 * @param config {Object} (Optional, Default: 'mongodb' object in config/app.js)
 */
exports.createInstance = function(instanceConfig) {
  var mongodb = new MongoDb();
  mongodb.config = instanceConfig || config;
  return mongodb;
};

var MongoDb = function() {};

// Ex. allow insertLog() to trigger secondary serializations.
_.extend(MongoDb.prototype, EventEmitter.prototype);
github Mockgoose / Mockgoose / lib / Collection.js View on Github external
'use strict';

var logger = require('./Logger');
var ObjectId = require('mongodb').BSONPure.ObjectID;
var _ = require('lodash');

var db = require('./db');
var utils = require('./utils');
var filter = require('./options/Options');
var validation = require('./validation/Validation');
var operations = require('./operations/Operations');

module.exports = Collection;
function Collection(mongoCollection, Model) {
    var name = this.name = mongoCollection.name;
//    var opts = this.opts = mongoCollection.opts;
//    var conn = this.conn = mongoCollection.conn;
    /*jshint -W064 *///new operator.
    var schema = Model().schema;
    /*jshint -W106 *///Camel_Case
github luxdelux / redpack / jslib / index.js View on Github external
require.paths.unshift(__dirname);

var mongo = require('mongodb');
// var BSON = require('redpack/jslib/bson').BSON;
var BSON = require('mongodb').BSONPure.BSON;
var redis = require('redis');
var fs = require('fs');
var path = require('path');

const REQUEST_TYPE = 0;
const RESPONSE_TYPE = 1;
const REQ_QUEUE_PREFIX = 'redpack_request_queue:';
const RES_QUEUE_PREFIX = 'redpack_response_queue:';
const RES_QUEUE_ID_KEY = 'redpack_response_queue_index';
const BLPOP_TIMEOUT = 15; // timeout duration for server blpop

function Client(reqQueue, host, port) {
  this.reqQueue = REQ_QUEUE_PREFIX + reqQueue;
  this.count = 0;
  this.host = host;
  this.port = port;
github andresdominguez / protractor-meetup / server / routes.js View on Github external
var mongo = require('mongodb');
var _ = require("underscore");

var Server = mongo.Server,
    Db = mongo.Db,
    BSON = mongo.BSONPure,
    BANDS = 'bands',
    MEMBERS = 'members',
    ALBUMS = 'albums';

var bandApp = {};

var server = new Server('localhost', 27017, {auto_reconnect: true});
db = new Db('banddb', server);

db.open(function(err, db) {
  if (!err) {
    console.log("Connected to 'banddb' database");
    db.collection(BANDS, {strict: true}, function(err, collection) {
      if (err) {
        console.log("The collection does not exist, creating a new one");
        populateDB();
github vpulim / mongode / lib / db.js View on Github external
var createServer = function(server, options) {
    var parts = server.split(':'),
        host = parts[0],
        port = parseInt(parts[1] || 27017, 10);

    return new mongodb.Server(host, port, options);
};

var nameFromUri = function(url) {
    var urlRE = new RegExp('^mongo(?:db)?://(?:|([^@/]*)@)([^@/]*)(?:|/([^?]*)(?:|\\?([^?]*)))$');
    var match = url.match(urlRE);
    return match[3] || 'default';
}

exports.Database = Database;
exports.ObjectID = mongodb.BSONPure.ObjectID;
exports.BSON = mongodb.BSONPure;
github adrai / node-queue / lib / databases / mongodb.js View on Github external
'use strict';

var util = require('util'),
    Queue = require('../base'),
    _ = require('lodash'),
    mongo = require('mongodb'),
    ObjectID = mongo.BSONPure.ObjectID;

function Mongo(options) {
  Queue.call(this, options);

  var defaults = {
    host: 'localhost',
    port: 27017,
    dbName: 'queuedb',
    collectionName: 'queue'
  };

  _.defaults(options, defaults);

  var defaultOpt = {
    auto_reconnect: false,
    ssl: false
github hyperstudio / MIT-Annotation-Data-Store / node_modules / mongoose / lib / drivers / node-mongodb-native / binary.js View on Github external
/*!
 * Module dependencies.
 */

var Binary = require('mongodb').BSONPure.Binary;

module.exports = exports = Binary;
github mariano-fiorentino / amid / lib / rest.js View on Github external
amid

    Created by Tom de Grunt on 2010-10-03 in mongodb-rest
    New version Copyright (c) 2013 Mariano Fiorentino, Andrea Negro	
		This file is part of amid.
*/ 

var express = require('express');
var nodeExcel = require('excel-export');
var ObjectID = require('mongodb').ObjectID;

var mongo = require("mongodb"),
    app = module.parent.exports.app,
    config = module.parent.exports.config,
    util = require("./util"),
    BSON = mongo.BSONPure;

//return all db/collection
app.get('/db/:showCollList?', function(req, res) {
   
 
    var dab = new Array();
    var max=0;
    var maxColl=0;
    var presColl=0;
    var db = new mongo.Db('admin', new mongo.Server(config.db.host, config.db.port, {'auto_reconnect':true}));

    //array return  
    var ret = Array();
    db.open(function(err, db) {
        db.authenticate(config.db.username, config.db.password, function () {
github senecajs / seneca / plugin / mongo-store.js View on Github external
function makeid(hexstr) {
  if( mongo.BSONNative ) {
    return new mongo.BSONNative.ObjectID(hexstr)
  }
  else {
    return new mongo.BSONPure.ObjectID(hexstr)
  }
}