KEMBAR78
Mongo db workshop # 02 | PPTX
W O R K S H O P
S E S S I O N # 0 2
M I S S F A R H A T
CONTENT
 Introduction to Mongoose
 Introduction to NodeJs
 Introduction to Express
 Schemas and Models
 Installation of Compass
 CRUD Operation using Compass
CRUD Operation using Mongoose
INTRODUCTIONTO MONGOOSE
Mongoose is an Object Data Modelling (ODM) library for MongoDB
and Node.js. It manages relationships between data, provides schema
validation, and is used to translate between objects in code and the
representation of those objects in MongoDB.
https://mongoosejs.com/
const mongoose = require('mongoose');
mongoose.connect(‘mongodb://localhost:27017/test', {useNewUrlParser: true,
useUnifiedTopology: true})
.then ( () => console.log("Successful Connected"))
.catch( (err) => console.log(err));
INTRODUCTIONTO NODEJS
Node.js is a platform built on Chrome's JavaScript runtime for easily
building fast and scalable network applications. Node.js uses an
event-driven, non-blocking I/O model that makes it lightweight and
efficient, perfect for data-intensive real-time applications that run
across distributed devices.
https://nodejs.org/en/
Version: Latest version
Packages install: npm init -y
npm install mongoose
For CheckVersion: node –v
For Run Program: node run start
INTRODUCTIONTO EXPRESS
Express.js is a free and open-source web application framework for
Node.js. It is used for designing and building web applications quickly
and easily.
https://expressjs.com/
SCHEMAS AND MODELS
SCHEMAS:
Everything in Mongoose starts with a Schema. Each schema maps to a
MongoDB collection and defines the shape of the documents within
that collections.
const aptechSchema = new mongoose.Schema({
name: String,
Email: String,
Age: Number,
Date: {
type: Date,
default : Date.now
}
});
SCHEMAS AND MODELS
MODELS:
Models are fancy constructors compiled from Schema definitions. An
instance of a model is called a document. Models are responsible for
creating and reading documents from the underlying MongoDB
database.
const Aptech = new mongoose.model("Aptech",aptechSchema);
INSTALLATION OF COMPASS
https://www.mongodb.com
/try/download/compass
GUI OF COMPASS
GUI OF COMPASS
GUI OF COMPASS
GUI OF COMPASS

Mongo db workshop # 02

  • 1.
    W O RK S H O P S E S S I O N # 0 2 M I S S F A R H A T
  • 2.
    CONTENT  Introduction toMongoose  Introduction to NodeJs  Introduction to Express  Schemas and Models  Installation of Compass  CRUD Operation using Compass CRUD Operation using Mongoose
  • 3.
    INTRODUCTIONTO MONGOOSE Mongoose isan Object Data Modelling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB. https://mongoosejs.com/ const mongoose = require('mongoose'); mongoose.connect(‘mongodb://localhost:27017/test', {useNewUrlParser: true, useUnifiedTopology: true}) .then ( () => console.log("Successful Connected")) .catch( (err) => console.log(err));
  • 4.
    INTRODUCTIONTO NODEJS Node.js isa platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. https://nodejs.org/en/ Version: Latest version Packages install: npm init -y npm install mongoose For CheckVersion: node –v For Run Program: node run start
  • 5.
    INTRODUCTIONTO EXPRESS Express.js isa free and open-source web application framework for Node.js. It is used for designing and building web applications quickly and easily. https://expressjs.com/
  • 6.
    SCHEMAS AND MODELS SCHEMAS: Everythingin Mongoose starts with a Schema. Each schema maps to a MongoDB collection and defines the shape of the documents within that collections. const aptechSchema = new mongoose.Schema({ name: String, Email: String, Age: Number, Date: { type: Date, default : Date.now } });
  • 7.
    SCHEMAS AND MODELS MODELS: Modelsare fancy constructors compiled from Schema definitions. An instance of a model is called a document. Models are responsible for creating and reading documents from the underlying MongoDB database. const Aptech = new mongoose.model("Aptech",aptechSchema);
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.