Professional Documents
Culture Documents
LQ1. Explain Schema and Model in MONGODB in Details
LQ1. Explain Schema and Model in MONGODB in Details
Schema :
Model :
A model is a compiled version of the schema. One instance of the model will map to
one document in the database. It is the model that handles the reading, creating,
updating, and deleting of documents. A document in a Mongoose collection is a single
instance of a model. So it makes sense that if we're going to work with our data then it
will be through the model. A single instance of a model (like a User instance in var User
= mongoose.model('User', userSchema);) maps directly to a single document in the
database. With this 1:1 relationship, it is the model that handles all document interaction
- creating, reading, saving, and deleting. This makes the model a very powerful tool.
.