Access to all courses
Exploring Models
In Mongoose, a model is an interface to the database. It is a class that represents a collection of documents in the database. Models are responsible for creating and reading documents from the database, as well as updating and deleting them. To create a model in Mongoose, you need to define a schema that describes the structure of the documents in the collection. The schema defines the fields and their types, as well as any validation rules that should be applied to the data. This allows our model to enforce a consistent structure for the documents in the collection. ## What can a Model do? Once you have defined a model, you can use it to interact with the database. Models provide a number of methods for creating, reading, updating, and deleting documents in the collection. For example:
The rest of this lesson is waiting.
Join JS Mastery Pro to unlock it.





Get Full Access
$149 /month
Lock in a year & save—2 months free!
Quizzes, mini-challenges, AI summaries, inline sandboxes
Participation in a private community
Build real production-grade apps
Mock interviews & project reviews
Weekly live sessions & member-only access