An image

Corporate Blogs

Create a CRUD Application in Express JS and MongoDB

E-Commerce Businesses Need a Mobile App

In this blog, we will be learning how to create simple crud APIs in Express JS ( Node JS Framework ).
The Mean stack is used to describe development using MongoDB, Express.js, Angular.jS, and Node.js. Now, I will show you how to use Express.js, Node.js, and MongoDB.js. We will be creating a simple Node application that will allow users to input data they want to store in a MongoDB database, also showing all other data entered.

Install using Node, Express, MongoDB 


Express.js is a web application framework. It simplifies the server creation process that is already available in Node. Node allows you to use JavaScript as your server-side language.

We need to install express via npm


MongoDB is an open-source database. Mongoose is a client API for node.js, making it easy to access our database from our Express application.

We need to install MongoDB via npm.

Create a project in Express 

 For creating a project, we run the below command in the command prompt where you want to create.

Project Structure

MongoCrud- Package name
– product.controller.js

– product.model.js
– routes
– product.route.js
– node_modules
– app.js
– package.json

Create a Database Connectivity File

Here we can create a file in mongoose schemas and MongoDB connection. You should connect to MongoDB through the Mongo client’s connect method.


Create a Model Schema

Everything in Mongoose starts with a Schema. Each schema maps to a MongoDB collection and defines the type of the documents within that collection.


Create a Controller 

We created CRUD for communicating with the server. Now we will apply the real logic to the route and controller.

Create a  new student (POST request)

In the route, we don’t have to pass anything, Here we can upload the route file.


Get all student (GET request)

we will import Controller and apply getstudent method.

Update a single student (PUT method)

Remember that, without {new: true}, the updated document will not be returned.

In the routes,

Delete a single contact (DELETE method)

In the routes,

API Calls

Below are the all screenshots of all APIs call, which having REST APIs and results of these APIs.

Create API


Update API

Delete API

If you’re looking for highly experienced and talented Node.js developers, you can get in touch with technical advisors to find a developer at your affordable price. At Agira Technologies, we have flexible models that can help your development in better ways possible.

Turn your vision to magnificent reality With
Our Web and Mobile Solutions
Professional Life of an IT Consultant Interview with Valentin Crettaz
Written by
Junior software developer. She specializes in Java, Angular, JavaScript, Jquery, HTML and CSS. A chilled out tech enthusiast who is thriving to be the best on what she does. She enjoys playing video games and some pleasant music when she is not coding.

Leave a Comment

You have an Idea. We have the Solution.

We help business evolve with lates technologies and infrastructures tailored to their needs and market trends.