MongoDB single global connection made simple
require('kdb').load('mongodb://username:password@ip.address:port/', 'database');`
3. 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):
`js
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):
`js
require('kdb').load('mongodb://username:password@ip.address:port/', 'database', 'admin');
``