MongoDB Local Installation and Setup

  • Download MongoDB server from the  and install. ( i prefer community edition ).
  • For these instructions, let us assume that you have installed MongoDB to C:\ProgramFiles\MongoDB\Server\3.4\.
  • MongoDB requires a data directory to store all data, so lets create a folder and point the data path to that folder.
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath d:\test\mongodb\data
  • Now Start the MongoDB. Run the following code in command prompt.
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"

This starts the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.

  • To connect to MongoDB through the mongo.exe shell, open another Command Prompt.
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
  • In the Above mongo shell you can run some commands and play through it like ,
    • show dbs – Shows list of database
    • use dbName – Switch to that database
    • db.stats() – Gives the db status
    • show collections – Shows list of collections
    • db.collectionName.find() – List all the data in the collection

For More commands refer

For Accessing this MongoDB with Local Node ( Refer Link )


Simple App Using Bootstrap, AngularJS, NodeJS and MongoDB.

A simple try using Node and Mongo to develop a Finance APP. Posted in Git hub link HERE.

  • Frontend – HTML, Bootstrap.
  • Framework – AngularJS.
  • Backend – NodeJS.
  • Database – MongoDB.

MongoDB CRUD Using Mongoose

Initialize Mongoose and Schema

var mongoose = require('mongoose');
var schema = new mongoose.Schema({ name: 'string', account: 'string', date: 'string' });
var accountz = mongoose.model('accountz', schema);


   var small = new accountz({
        name: "SAMZ",
        account: "Monthly",
        date: "29/12/2015"
    }); (err) {
        if (err){
            console.log("Error in Save");
            console.log("Save Sucessfully");


   accountz.find().exec(function(err, data){
        if (err){
            console.log("Error in Reading");
            console.log("The value = " + data);


   accountz.findOne({ "_id": "0023"}, function (err, doc){ =;
        doc.account = editObj.account; =; (err) {
            if (err){
                console.log("Error in Updating");
                console.log("Updated Sucessfully");


    accountz.remove({ "_id": "0023"}).exec(function(err, data){
        if (err){
            console.log("Error in Deleting");
            console.log("Deleting Sucessfully");

You can refer to my github project Explore Here .

Get Users of a Room in NodeJs-SocketIO

In a chat using NodeJs / SocketIO, to get the all user using a room can be found by following code,

function get_users_by_room(nsp, room) {
  var users = []
  for (var id in io.of(nsp).adapter.rooms[room]) {
  var roomUsers = [];
          id :,
          name :,
          roomName : elem.rName
  return roomUsers;

This can be used to find the online users.