1. Mongoose is an ODM(object data modeling) library for mongoDB and Node.js,
higher level of abstraction for mongodb.
2. **Features:** schemas to model data and relationship,easy data validation,
simple query Api,middleware etc.
3.**Schema**(describe structure of data) into
**Model**(wapper for schema,providing interface for crud operation)
//==== 4)Creating simple tour model===
//server.js
const mongoose= require('mongoose')
const tourSchema= new mongoose.Schema({
//basic
name:String,
rating:Number,
price:Number,
//using schema type options
name:{ type:String,required:[true,'A tour must have a name']},
rating:{ type:Number,default:4.5},
price:{type:Number, required:true}
})
const Tour= mongoose.model('Tour',tourSchema);