This package has been deprecated
Author message:
Renaming to mongo-lazy-connect
mongo-connect-sync
1.2.2 • Public • Published
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);
});
});
Package Sidebar
Install
Weekly Downloads