Skip to content

mdhelaluddin-ctg-bd/nodejs-mongodb-crud-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRUD REST API with Node.js and MongoDB

CRUD

CRUD stands for Create, Read, Update and Delete. These are the basic operations almost every simple web app would be designed to achieve.

REST

If you don’t have the idea about REST API, you can visit the below link and learn the basic about REST API. https://restfulapi.net

Prerequisites

  1. You must have Node.js and MongoDB installed in your pc.
  2. Optionally you can install MongoDB Compass to manage MongoDB using GUI

NPM Packages

  1. ExpressJS Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  2. mongoose Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
  3. body-parser Node.js body parsing middleware.Parse incoming request bodies in a middleware before your handlers, available under the req.body property.

Instructions

  1. Clone the project from github using the following command
git clone https://github.com/mdhelaluddin-ctg-bd/nodejs-mongodb-crud-api.git
  1. Enter to the project directory and Install node mudules
npm install
  1. Run index.js file
node index.js

There you go! You might wonder the below output in your terminal.

Node.js and MongoDB CRUD app is listening on port 3000!

POSTMAN

You can install POSTMAN as chrome extension to test apis.

API

Create or Enter new product information to your databas table

Method : POST
URL : http://localhost:3000/products/create
Parameters : name, description, price
if you are using POSTMAN, set parameters from BODY > x-www-form-urlencoded

Get product information by ID

Method : GET
URL : http://localhost:3000/products/[PRODUCT-ID]

Update product information usding product id

Method : PUT
URL : http://localhost:3000/products/[PRODUCT-ID]
Parameters : name, description, price
if you are using POSTMAN, set parameters from BODY > x-www-form-urlencoded

DELETE product information by ID

Method : DELETE
URL : URL : http://localhost:3000/products/[PRODUCT-ID]

Congrats !!! You are done...

If you are still facing any problem feel free to contact with me at [email protected] or you may create issue. I will try to response back to you asap. Thanks.

Releases

No releases published

Packages

No packages published