We might need to store more information about the author than just their name, and there might be multiple authors with the same or similar names.
We want to be able to sort information based on book title, author, genre, and category.
At time of writing Mongoose is by far the most popular ORM, and is a reasonable choice if you're using Mongo DB for your database.
For the example (and the rest of this topic) we're going to use the Mongoose ODM to access our library data.
For more information on the options see: Database integration (Express docs).
It then goes on to show how we can use Mongoose to provide database access for the Local Library website.
The obvious candidate for a model of this type is the book genre (e.g.
Science Fiction, French Poetry, etc.) Once we've decided on our models and fields, we need to think about the relationships between them.
This ODM and database combination is extremely popular in the Node community, partially because the document storage and query system looks very like JSON, and is hence familiar to Java Script developers.
The rest of this tutorial shows how to define and access the Mongoose schema and models for the Local Library website example.