Thanks for visiting my GitHub account!
MongoDB is a document database. It stores data in a type of JSON format called BSON. Also, MongoDB is a source-available, cross-platform, document-oriented database program. Classified as a NoSQL database product, MongoDB utilizes JSON-like documents with optional schemas. see-more
- VS Code, Download ->https://code.visualstudio.com/download
- Node, Download-> https://nodejs.org/en/download
- MongoDB Shell(msi) , Download-> https://www.mongodb.com/try/download/shell
- MongoDB Compass (msi), Download-> https://www.mongodb.com/try/download/community
- Postman, Download-> https://www.postman.com/downloads/
Or Online Database (MongoDB Atlas)
- Register -> https://www.mongodb.com/cloud/atlas/register
-
Install Node.js
-
To verify installation into command form by node -v
-
For initialization npm write the query in the command window as npm init -y
-
Setup the opening file into the package.json and change the file with main:'server.js'
-
To create a server using the express package then write a query into the command window as npm install express. Write code in the server file for initialization const express = require("express"); const app = express(); app.listen(3000, () => { console.log("Server is running at http:https://localhost:3000"); });
-
Install the nodemon package for automatically running the server as- npm i --save-dev nodemon (For Developing purpose)
-
setup the package.json file in the scripts key, write "scripts": { "start": "node ./resources/backend/server.js", "dev": "nodemon ./resources/backend/server.js", "test": "echo "Error: no test specified" && exit 1" },
-
use the Morgan package for automatic restart. Hence install the morgan package as npm install --save-dev morgan (Development purpose) Write code in the server file for initialization const morgan = require("morgan"); app.use(morgan("dev")); --> Middlewire.
-
Install Postman software for API testing by the URL endpoint.
-
Install Mongobd + MongobdCompass and Mongoshell (For Database)
- Install Mondodb + Mongodb Compass and Mongodb Shell download from the google.
- Set up Environment Variable in drive:c/program file
- Create a directory in the base path of the c drive named data. Inside the data directory create another folder db.
- Write the command in the CMD window as Mongod. And write the other command in the other CMD window as mongosh.
- Then Check the version as mongod --version and mongosh --version.
- Install mongoose package as npm i mongoose
- Create an atlas account. In the atlas account create a cluster that have a user(as atlas admin) and network access with any access IP address.
- Connect the database using URL from the atlas cluster or local Mongodb compass using the mongoose package as mongoose. connect('mongodb:https://localhost:27017/database-name);
- clone to your local machine
- Run command in the Root directory
npm install
npm start
- Import database and postman file (if Needed)
- run the project in the postman using path ->
http:https://localhost:8001
- Node JS
- Express JS
- uuid
- Create -> insertOne() / insertMany()
- Read -> find() / findOne()
- Update -> update() / updateOne()
- celete -> delete() / deleteOne()
- GET: /api/products -> return all products (
http:https://localhost:8001/api/products
) - GET: /api/products/:id -> return single product(
http:https://localhost:8001/api/products/product-id
) - DELETE: /api/products/:id -> delete the product(
http:https://localhost:8001/api/products/product-id
) - PUT: /api/products/:id -> update the product(
http:https://localhost:8001/api/products/product-id
) - POST: /api/products/ -> create the product(
http:https://localhost:8001/api/products/add-product
)
- Connect the databse
- Create a schema and model(collecttion/table)
- Create data in the databse
- Read data from the databse
- Update data from the databse
- Delete data from the databse
Note: create the database -> crated the collection -> create many documents