I am new to node programming, and I have got the following question:
why do "database connected" and "handleDataResult" not log correctly in the node console when I launch my script using node index.js command?
My code logs only "no callback" and exits immediately.
const mongojs = require('mongojs');
var url = "mongodb://<username>:<password>@ds237748.mlab.com:37748/anbieter";
var db = mongojs(url);
var mycollection = db.collection('Anbieter');
db.on('connect', function () {
console.log('database connected')
});
db.mycollection.find({}, handleDataResult);
var handleDataResult = function (err, docs){
console.log("handleDataResult");
}
console.log("no callback");