Additional Objects

Mongoose sits on top of the MongoDB Node.js native driver and extends its functionality in a couple of different ways. First, it adds some new objects—Schema, Model, and Document—that provide the functionality necessary to implement the ODM and validation.

You use the Schema object to define the structured schema for documents in a collection. It allows you to define the fields and types to include, uniqueness, indexes, and validation. The Model object acts as a representation of all documents in a collection. The Document object acts as a representation of an individual document in a collection.

Mongoose also wraps the standard functionality used for implementing query and aggregation parameters into the new objects Query and Aggregate that allow you to apply the parameters of database operations in a series of method calls before finally executing them. This can make it simpler to implement code as well as reuse instances of those objects to perform multiple database operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.106.212