First, we need to include a few packages for our Nodejs application.
npm install express --save
Express allows us to set up middlewares to respond to HTTP Requests.
npm install body-parser --save
If you want to read HTTP POST data , you have to use the “body-parser” node module.
npm install mongoose --save
Mongoose is an object document modeling (ODM) layer which sits on the top of Node’s MongoDB driver.
app.js This is the main executable application file
Start the MongoDB.
Run app.js file
Go to the browser and open http://127.0.0.1:3000/
Fill the above form
This will add a record named “David Smith” in MongoDB.
Let’s have a check in MongoDB for the same record.
The record is now saved in the “gfg” database in “details” collection.
- Nodejs - Connect MongoDB with Node app using MongooseJS
- Nodejs | Automatic restart NodeJs server with nodemon
- Amazon auto signup script
- Nodejs | DNS
- MongoDB and Python
- MongoDB: Getting Started
- MongoDB vs MySQL
- MongoDB : An introduction
- Web-Socket in NodeJS
- Nodejs | DNS | setServers()
- Nodejs | Jimp
- Difference between RDBMS and MongoDB
- Introduction about Node.js and MongoDB
- Encrypting Data in NodeJS
- Nodejs | Web Crawling using Cheerio
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : latikesh2121