This package has been deprecated

Author message:

Renaming to mongo-lazy-connect

mongo-connect-sync

1.2.2 • Public • Published

npm version build status coverage status

Similarly to other DBs, let's allow a "synchronous" access to the MongoDB driver pool

const db = require('mongo-connect-sync')('mongodb://localhost:27017/connect-sync-test');
 
const coll = db.collection('foo');
coll.insertOne({bar: 2}).then(() => {
    coll.find({}).limit(5).toArray().then(console.log);
});

is equivalent to:

const MongoClient = require('mongodb');
 
MongoClient.connect('mongodb://localhost:27017/connect-sync-test')
    .then(db => {
        const coll = db.collection('foo');
        coll.insertOne({bar: 2}).then(() => {
            coll.find({}).limit(5).toArray().then(console.log);
        });
    });

/mongo-connect-sync/

    Package Sidebar

    Install

    npm i mongo-connect-sync

    Weekly Downloads

    2

    Version

    1.2.2

    License

    ISC

    Last publish

    Collaborators

    • caub