npm.io
1.2.2 • Published 8 years ago

mongo-connect-sync

Licence
ISC
Version
1.2.2
Deps
1
Vulns
1
Weekly
0
Stars
8
DeprecatedThis package is deprecated

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