Object-relational Mapping is a programming technique used to make more readable the way we use database query statements in other languages different from SQL / NoSQL.
sequelize is one of the most used libraries to work with ORM in JS. It supports the most used database types like PostgreSQL, MariaDB, MySQL, SQLite and Microsoft SQL Server.
When developing a project, we can follow one of two different patterns defined by Martin Fowler:
The Entity Model doesn’t interact with the database. It is only there so it can be used by Entity Mapper to make operations in the database (View and Model are separated)
The Entity Model interacts with the database. Every method is directly linked, they are all in the same file (View and Model are in the same file).
npm init -y
npm i sequelize sequelize-cli mysql2
npx sequelize-cli init
This last command will create the following folders: /config, /migrations, /models & /seeders.
JWT is a token generated with the HMAC algorithm by codifying some information.
The token generation is based in personal user information and a secret known just by the server.