Now the question is how to perform some simple operations like looping through the objects in collection. This article assumes that you have already installed the core MongoDB library using Node Package Manager (NPM).
sudo npm install mongodb
Now the very first step is to declare the variables pointing to the ‘MyDB’ database in MongoDB:
// MongoDB Connection
var Db = require('mongodb').Db, Connection = require('mongodb').Connection, Server = require('mongodb').Server, BSON = require('mongodb').BSONNative; var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT']…
View original post 97 more words