Node JS - Node js Create Connection with MongoDB - MongoDB - Node - Node JS tutorial - webnode
Related nodejs article tags - node js - node js tutorial - node js examples
How to Create Connection of MongoDB in Node.js?
- MongoDb is a NoSQL database.
- It can be used with Node.js as a database to insert and retrieve data.
- NoSQL database such as MongoDB have become quite popular as databases for storing data.
- The ability of these databases to store any sort of content and particularly in any sort of format is what makes these databases so famous.
- Node.js has the ability to work with MongoDB as databases.
- In order to use either of these databases, you need to download and use the required modules using the Node package manager.
- For using MongoDB the required module to be installed is "Mongoose."
Option 1 : For Windows To download and install MongoDB on windows. Manually download the mongodb install software from https://www.mongodb.com/download-center
- Extract the archive where you want to
- Optional: add mongoDB path to your system PATH
- Create C:\data\db folder (or /data/db according to your OS)
- Run mongoDB server via the console: use the mongod command
- DO NOT CLOSE THE CONSOLE ONCEMONGODB IS LAUNCHED!
- We need a driver
- we install it with npm!
Option 2 : For Linux Open the Linux Command Terminal and execute the following command:
apt-get install mongodb
It will download the latest MongoDB according to your system requirement.
Learn Node js - node js Tutorial - download in node.js mongodb connection - - node - Node js Examples
- After the complete download, use the following command to install MongoDB.
- npm install mongodb --save
- Use the following command to start MongoDb services:
- service mongodb start
Learn Node js - node js Tutorial - installation in node.js mongodb connection - - node - Node js Examples
- Now, connection is created for further operations.