Defining and Using Sequelize Models
For our Avalon Airlines project that we introduced in the previous chapter, we will need to instruct our application on how we want to define our database’s schematics. A database can have various roles and applications but only a single purpose, and that purpose is to organize our data (storage is the filesystem’s job). Before we can begin defining our models within the Node.js application, we need to think about the entities of our business logic and models from a project’s perspective (and each project will have different requirements). Most projects will structure their schema in a way that categorizes organizations (for example, customers, employees, vendors, and companies) and things such as products, planes, and receipts from transactions.
Object-relational mapping (ORM) helps us ensure that the database is organized from the data and team’s perspective. Sequelize will help us manage the nomenclature for...