Configure Sequelize
In order to be able to use Sequelize, we have first to set up the connection between sequelize and our database.
In order to do that, we will create the DatabaseModule
, which will contain the provider of the sequelize instance.
In order to set up this connection, we will define a configuration file, which will have as properties all you need to be connected to your database. This configuration will have to implement the IDatabaseConfig
interface in order to void to forget some parameters.
export
interface
IDatabaseConfigAttributes
{
username
:string
;
password
:string
;
database
:string
;
host
:string
;
port
:number
;
dialect
:string
;
logging
:boolean
|
(()
=>
void
);
force
:boolean
;
timezone
:string
;
}
export
interface
IDatabaseConfig
{
development
:IDatabaseConfigAttributes
;
}
This configuration should be set up as the following example, and set the parameters through the environment variable or the default value.
export
const...