🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mongodb-connector

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

mongodb-connector

Simple wrapper for mongodb.MongoClient

unpublished
latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

mongodb-connector

Simple wrapper around the MongoClient.connect method

Can include an optional collections array on the options object so that your collections can be accessed via the returned mongodb instance object.

var options = {
  collections: ['collectiona','collectionb','collectionc']
};

see [mongodb options](https://docs.mongodb.org/v3.0/reference/connection-string/#connections-connection-options) for other valid properties for he options object.

install
$npm install --save --production mongodb-connector

usage

const MongoConnector = require('mongodb-connector');

let url = 'mongodb://localhost:27017/test_db';
let options = {
  collections: ['collectiona', 'collectionb', 'collectionc']
}

new MongoConnector().connect(url, options).then(function(db){
  db.collectiona.insertOne({name: 'test'}).then(function(){
    //access to the default returned db instance
    db.db.collection('collectiona').insertOne({name: 'test2'}).then(function(){
      db.close();
    });
  });
}, function(error){
    console.log(error);
});

Keywords

mongodb

FAQs

Package last updated on 14 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts