Hello
What is the best practice to open and close a MongoDB connection in a node.js web app? Currently, I am opening the connection and I am starting the webserver in the corresponding callback function:
db.open(function(err, db) {
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
});
Is this best practice? And where should I close the connection? Is closing the connection not necessary?
Best
David