Skip to content

Instantly share code, notes, and snippets.

@binyamin
Created April 5, 2020 16:27
Show Gist options
  • Save binyamin/51522a28c8458e7838a111a0e20857a4 to your computer and use it in GitHub Desktop.
Save binyamin/51522a28c8458e7838a111a0e20857a4 to your computer and use it in GitHub Desktop.
Mongo DB Utils
const mongoClient = require('mongodb');
const url = 'mongodb://localhost:27017';
var _db;
module.exports = {
connectToServer: function(cb) {
mongoClient.connect(url, { useNewUrlParser: true }, function(err, client) {
_db = client.db('taskit');
return cb(err);
})
},
getDb: function() {
return _db;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment