I want to use mongodb with sails but without any ORM. So below is my service to connect mongodb.
Service:
//DbService.js
const MongoClient = require(\'m
As you can see in docs MongoClient.connect()
doesn't return Promise object. Instead of this use callback function
module.exports = {
db:function(){
var connect = MongoClient.connect("mongodb:***********", function (err, database) {
//...
}
});
}
}
btw. Your call DbService.db
function in controller will also fail, cuz your service function also doesn't return Promise
Before you go on, read something about Promises and callback functions