kdb
v1.0.2
Published
MongoDB single global connection made simple
Downloads
7
Readme
kdb - MongoDB single global connection made simple
Features
-Optimal boilerplate code minimization.
-Wraps the official MongoDB package.
Tutorial
- In the command line, type: npm i kdb
- Add this line anywhere in the code (preferably on top level code, not inside a function):
require('kdb').load('mongodb://username:[email protected]:port/', 'database');
- You can now command your database normally (refer to MongoDB official documentation as this is a wrapper around it and works the exact same way aside from making connection easier):
const db=require('kdb');
function example(){
var cursor= db.connection('example').find();
//etc.
}
Further Info:
If you're having a problem with authentication, you can change authSource by adding it as a third parameter to the load function to solve it (Refer to official MongoDB documentation for more info):
require('kdb').load('mongodb://username:[email protected]:port/', 'database', 'admin');