1.0.1 • Published 4 years ago

mongo-using v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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