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
- MongoDB: Getting Started
- MongoDB and Python
- MongoDB : An introduction
- MongoDB vs MySQL
- Nodejs | DNS
- Difference between RDBMS and MongoDB
- Introduction about Node.js and MongoDB
- Nodejs | DNS | setServers()
- Nodejs | Jimp
- Web-Socket in NodeJS
- MongoDB | Delete Database using MongoShell
- MongoDB | Create Database using MongoShell
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