Create Model
Last updated
Was this helpful?
Last updated
Was this helpful?
The first step is to identify the actors in our application. In this case, we can consider a user and a book as our models. Great! We can now create our classes in the models folder (We will not create a user class since it is already created).
We will use mongoose as our ORM.
Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
Mongoose. (n.d.). Retrieved from
In our case, the book has three attributes, where we define for each attribute its type and other validations.
Note that each book has a unique ISBN and an ISBN is a number that has either 10 or 13 digits.