We use Node.js and Mongodb together when we need to use Node.js in Database Applications.
Mongodb is a NoSQL database. Its a document based Database. The benefits of using NoSQL database instead of traditional database are-
– A Relational database has a typical schema design that contains tables and the relations between them but in NoSQL database like Monogdb there is no concept of relationship.
– It is a document oriented database in which one collection holds different documents.
– It’s Extremely faster than RDBMS.
– In MongoDB data is written in BSON format which is a JSON like format.
– Mongodb can be used where data is big and complex.

To connect to MongoDB from Node.js Application-

1) Firstly we need to install Mongodb.

2) You also need to install package of mongodb.

For this, use the following step:-

-In your command prompt type npm install –save mongodb.(If it Is already installed then this command will update your mongodb).

3) To start Mongodb , use these steps:-

-Copy the path where your mongodb is installed in your system.
-Go to command prompt and type cd give space and paste this path like : –

cd C:\Program Files\MongoDB\Server\3.4\bin. ( you can also set the environment variable to start mongodb). By doing this we reach to that directory. Now you need to start mongodb server.

4) To start mongodb server-

Type mongod and hit enter in your command prompt. (it starts installation, your mongodb server will start at the port number 27017. To confirm this go to your browser and type localhost:27017 and hit enter. If it will display this message “It looks like you are trying to access MongoDB over HTTP on the native driver port.” It means your server has been started.

5) To manage mongodb, these are several GUI like compass, studio 3d , mongobooster(NoSQL booster). So you need to install one of them in your system.
In Mongobooster you can create your own Database, Collections(tables), Tuple/Row(Document) Or you can create them using Node.js.

Note-In mongodb table is known as collection and the record/tuple is known as Document.

Learn More-