1.2.2 • Published 6 years ago
mongo-connect-sync v1.2.2
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);
});
});