Chapter 3. Schemas and Models

We are going to look at the two building blocks of Mongoose, schemas, and models. We will look at their relationship to the data and how they can be used to maximize the effectiveness of Mongoose. This chapter covers fairly simple schemas; more complex schemas will be explored in Chapter 10, Complex Schemas.

By the end of this chapter, you will understand the roles of schemas and models and their relationship to the data. We will also add schemas and models to the MongoosePM example project.

Introducing schemas

So what is a schema? At its simplest, a schema is a way to describe the structure of data. Typically this involves giving each piece of data a label, and stating what type of data it is, for example, a number, ...

Get Mongoose for Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.