The tests pass, and everything works if it happens to occur inside a listener like so:
mongo.addListener("connection", function () {
mongo.getCollection('widgets').count(null, function(count) { sys.puts(count) })
})
However, when I try to do this in any other context, the callback never happens. For example, if I set up a server like this, and hit it, nothing is printed to the console.
var port = 8000
http.createServer(function (req, res) {
mongo.getCollection('widgets').count(null, function(count){
sys.puts("found stuff!")
})
}).listen(port)
In fact, even if I put this createServer stuff inside of a connection callback, it still doesn't work.
The tests pass, and everything works if it happens to occur inside a listener like so:
However, when I try to do this in any other context, the callback never happens. For example, if I set up a server like this, and hit it, nothing is printed to the console.
In fact, even if I put this createServer stuff inside of a connection callback, it still doesn't work.