can anyone share seprate MongoDB connect file ,server.js file and controller.js for rest Api exmaple :MY database connection is in mongodb.js ;My server listen on server.js;My All rest APis in Apis.js ;
db.js
var mongodb = require('mongodb');
module.exports.init = function (callback) {
var server = new mongodb.Server("localhost", 27017, {});
new mongodb.Db('agenda', server, {w: 1}).open(function (error, client)
{
//export the client and maybe some collections as a shortcut
module.exports.client = client;
module.exports.myCollection = new
mongodb.Collection(client,'agendaJobs');
callback(error);
});
};
via Manish Kumar Jha
No comments:
Post a Comment