mongo-using
v1.0.1
Published
Implement 'using' idiom for mongo connections in nodejs.
Downloads
3
Readme
mongo-using
A trifle, really. An implementation of scoped use for a mongo connection. See c-sharp 'using' or Python 'with'.
Installation
npm install mongo-using
Interface
import {db} from 'mongo-using';
var array = await db.use( mongo_url, mongo_dbname, async (db) => {
return await db.collection('collection_name').find().toArray();
}); // db connection is closed when you leave the scope
console.log(array);