MongoDB and mongoose MongoDB and mongoose mongoose mongoose

MongoDB and mongoose


Everything in Mongoose starts with a Schema. Each schema maps to a MongoDB collection and defines the shape of the documents within that collection.

var mongoose = require('mongoose');var Schema = mongoose.Schema;var personSchema = new Schema ({    firstname: {type: String, required: true},   lastname: {type: String, required: true}});

To use our schema definition, we need to convert our personSchema into a Model we can work with. To do so, we pass it into:

var Person = mongoose.model('Person', personSchema);

To more information enter link description here