Chapter 6. Sequelize
Sequelize is a promise-based ORM working for Node.js v4 and later. This ORM supports many dialects, such as:
PostgreSQL
MySQL
SQLite
MSSQL
This provides a solid support for transactions. With Sequelize you have the possibility of using sequelize-typescript
, which provides decorators to put in your entity and manages all the fields of your model, with types and constraints.
Also, Sequelize comes from many hooks providing you with the significant advantage of being able to check and manipulate your data at any level of the transaction.
In this chapter, we will see how to configure your database using postgresql
and how to configure the connection to your database. After that we will see how to implement our first entity, which will be a simple User
entity and then how to create a provider for this entity in order to inject the entity into a UserService
. We will also see the migration
system through umzung
, and how to create our first migration file.
You can have...