This package has been deprecated

    Author message:

    this package has been deprecated

    mongodb-connector

    1.0.1 • Public • Published

    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);
    });

    Install

    npm i mongodb-connector

    DownloadsWeekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • weagle08