@syolab/mongoclient
v1.3.0
Published
async mongo db client constructor
Downloads
6
Readme
Mongo Db Client
This is a Mongo DB Client wrapper
Installing with npm
npm install @syolab/mongoclient --save
using in node js
create client
const mongoClient = require('mongoClient');
let client = await new mongoClient({
url: 'mongo db connectionstring',
db: 'database name',
collection: 'collection name'
});
get the collection
let collection = await client.getCollection();
then, for example, do a query
let res = await collection.findOne()
don't forget to close the connection on termination
client.closeConnection()