I have a simple js file I'm executing with node script.js that does some async stuff.
However, the script exits before the callbacks execute. I read that node "waits until callbacks are ran before exiting." This doesn't seem to be the case - what am I doing wrong?
// script.js
asyncOp(function(err, result) {
console.log('callback'); // <- this doesn't happen
}
Edit: Here is a concrete example. This is the entire script
// script.js
var User = require('../models/user'); // a mongoose model
User.create({name: "bob"}, function(err, user) {
console.log('callback'); // <- this doesn't happen
};
I execute it with node script.js, but it exits before "callback" gets printed
create()method to be executed mongoosejs.com/docs/models.html