I’m writing some simple web app with Node.JS and want to use mongoDB as main data storage.
Node-mongodb-native driver requires to make chained calls before you actually can query or store data (open DB connection, authenticate, get collection).
Where is the best place to do this initialization – within each request handler or globally, when initializing application?
I’m writing some simple web app with Node.JS and want to use mongoDB as
Share
You are MUCH better putting the Mongo initialization outside of your request handler – otherwise it will re-connect for every page that is served: