“hello world” steps to start coding with MondoDB, NodeJS and Mongoose

This steps will use Mongoose Object data model. Just so that i don’t forget the simple syntax i will keep it posted here.

Installation:  (Skip steps which are already done)

Mongodb –

Then navigate to your project folder and install express, node, bla bla bla stuffs.. Guessing we did that already.Next..

Add mongoose to the project

Now coding.

Add Mongoose dependency:

Add MongoDB connection

Define a schema. This is like table structure but in a different format.

The above code is good enough to display if you have any data in your database, but you will need the below code to display it.

To display use this:

To add data, once the schema is defined add the following:

Add good reference tutorial is this: http://cdnjs.com/libraries/backbone.js/tutorials/nodejs-restify-mongodb-mongoose