/mongobasics

Primary LanguageJavaScript

MongoDB Basics

  • Cloud Based MongoDB Server - Atlas

Connect to MongoDB Database and read write documents

  • Create account on mongodb.com/atlas/database
  • Cluster0 will be available by default

Prerequisites

  • ENV file reader (dotenv)
  • REST APi server (express)
  • Parsing Middleware (body-parser)
  • Mongo Client (mongodb)

Commands

npm install --save dotenv
npm install --save express
npm install --save body-parser
npm install --save mongodb

Connection string

  • Copy connection string from Atlas server
  • Keep secrets in .env file and substitute them in the connection string

Learn how to use ORM mongoose

  • Create account on mongodb.com/atlas/detabase
  • Cluster0 will be available by default

Prerequisites

  • ENV file reader (dotenv)
  • REST APi server (express)
  • Parsing Middleware (body-parser)
  • Mongoose (ORM for Mongodb, mongoose)

Commands

npm install --save dotenv
npm install --save express
npm install --save body-parser
npm install --save mongoose