This repository contains the code for a CRUD (Create, Read, Update, Delete) API implemented using Node.js, Express.js, and MongoDB.
- Create: Allows users to create new product in the database.
- Read: Retrieves data from the database.
- Update: Allows users to modify existing data in the database.
- Delete: Removes data from the database.
-
Clone this repository to your local machine.
git clone https://github.com/Varunyadavgithub/CRUD-API.git
-
Install dependencies.
npm install
-
Set up MongoDB:
-
Ensure MongoDB is installed on your system.
-
Create a
.env
file in the root directory of the project. -
Inside the
.env
file, add the MongoDB connection string in the following format:MONGODB_URI=mongodb://localhost:27017/your-database
-
-
Start the server.
npm start
- Use POST requests to create new product.
- Use GET requests to retrieve product from the database.
- Use PUT requests to update existing product.
- Use DELETE requests to remove product from the database.
POST /api/products
: Create a new products.GET /api/products
: Retrieve all products.GET /api/products/:id
: Retrieve a specific products by ID.PUT /api/products/:id
: Update a specific product by ID.DELETE /api/products/:id
: Delete a specific product by ID.