monwrap
It wraps all Methods of mongodb collection api.
The official MongoDB driver is multi-functional. However, "close db" or "requires toArray () when finding" is troublesome. This wrapper simplifies them.
Install
$ npm install monwrap
Usage
const MongoWrapper = const settings = user: 'username' pass: 'password' dbName: 'database_name'const mongo = settings 'collectionName'await mongoconst items = await mongo
API
node-mongodb-native Class: Collection
static API
toBulkArray(array, idName = '_id')
const MongoWrapper = const data = _id: 1 a: 11 MongoWrapper/* ->[ { 'updateOne': { 'filter': { '_id': 1 }, 'update': { '_id': 1, 'a': 11 }, 'upsert': true } }]*/ const data = x: 1 a: 11 MongoWrapper/* ->[ { 'updateOne': { 'filter': { '_id': 1 }, 'update': { '_id': 1, 'a': 11, x: 1 }, 'upsert': true } }]*/
Related
mongodb The official MongoDB driver for Node.js. Provides a high-level API on top of mongodb-core that is meant for end users.
License
MIT © Mick Whats