Git Product home page Git Product logo

mongodb-crud-app's Introduction

MONGODB-CRUD-APP-WITH-POSTMAN

Youtube Facebook Instagram LinkedIn

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

CODE EXAMPLE

Source Code (Download)

Click Here

Required Software (Download)

Or Online Database (MongoDB Atlas)

========== Environment Setup ==========

  1. Install Node.js

  2. To verify installation into command form by node -v

  3. For initialization npm write the query in the command window as npm init -y

  4. Setup the opening file into the package.json and change the file with main:'server.js'

  5. 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://localhost:3000"); });

  6. Install the nodemon package for automatically running the server as- npm i --save-dev nodemon (For Developing purpose)

  7. 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" },

  8. 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.

  9. Install Postman software for API testing by the URL endpoint.

  10. Install Mongobd + MongobdCompass and Mongoshell (For Database)

========== Connect MongoDB Database ==========

  1. Install Mondodb + Mongodb Compass and Mongodb Shell download from the google.
  2. Set up Environment Variable in drive:c/program file
  3. Create a directory in the base path of the c drive named data. Inside the data directory create another folder db.
  4. Write the command in the CMD window as Mongod. And write the other command in the other CMD window as mongosh.
  5. Then Check the version as mongod --version and mongosh --version.
  6. Install mongoose package as npm i mongoose
  7. 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.
  8. Connect the database using URL from the atlas cluster or local Mongodb compass using the mongoose package as mongoose. connect('mongodb://localhost:27017/database-name);

How to use this project

  • 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://localhost:8001

Project includes

  • Node JS
  • Express JS
  • uuid

Project Features

CRUD

  • Create -> insertOne() / insertMany()
  • Read -> find() / findOne()
  • Update -> update() / updateOne()
  • celete -> delete() / deleteOne()

Route List

  • GET: /api/products -> return all products (http://localhost:8001/api/products)
  • GET: /api/products/:id -> return single product(http://localhost:8001/api/products/product-id)
  • DELETE: /api/products/:id -> delete the product(http://localhost:8001/api/products/product-id)
  • PUT: /api/products/:id -> update the product(http://localhost:8001/api/products/product-id)
  • POST: /api/products/ -> create the product(http://localhost:8001/api/products/add-product)

Working Process

  1. Connect the databse
  2. Create a schema and model(collecttion/table)
  3. Create data in the databse
  4. Read data from the databse
  5. Update data from the databse
  6. Delete data from the databse

Note: create the database -> crated the collection -> create many documents

Follow Me

github facebook instagram twitter YouTube

mongodb-crud-app's People

Contributors

learnwithfair avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.