5.
Create a NodeJS server using Express that creates, reads, updates and deletes students'
details and stores them in MongoDB database. The information about the user should be
obtained from a HTML form.
Step 1: First we need to setup the environment.
Step 2: Create a new folder with any name (Ex: ExpressMongoDb).
Step 3: Command to create Nodejs project npm init -y
Step 4: Next install express, mongoose
Command: npm install express , npm install mongoose
Express – for server,
Mongoose – for database
Step 5: Run the program
Step 6: Open server at the port , Here localhost: 8000
Values inserted in the Database:
Program Explanation:
• First we are importing modules express and mongoose,
• Next we are connecting monodb by [Link]() method. Copy the link
connection String in MongoDb Atlas at Drivers section.
• Next we are creating a Schema of our Collection and we are naming the collection as
“Students”.
• Next we are performing CRUD operations our Collection.
• Next we are viewing the all the documents inserted in Database.
• You can also view the inserted documents in the inserted Database.