Summary
In this chapter you have seen how to set up the connection to the database by instanciating a Sequelize instance, using the factory in order to inject the instance directly in another place.
Also, you have seen decorators provided by sequelize-typescript in order to set up a new model. You have also seen how to add some constraints on the columns and how to use the lifeCycle hooks to hash a password before saving it. Of course, the hooks can be used to validate some data or check some information before doing anything else. But you also have seen how to use the @BeforeCreate
hook. You are therefore ready to use a Sequelize transaction system.
Finally, you have seen how to configure umzung to execute migrations, and how to create your first migration in order to create the users table.
In the next chapter you will learn how to use Mongoose.