DB connection by Sequelize object

Hey hope you’re doing great guys!!! :slight_smile:

I was trying to use another way to connect forest to my db, right now I have the code from forest to connect to my DB :

module.exports = [{
  name: 'default',
  modelsDir: path.resolve(__dirname, '../src/models'),
  connection: {
    url: `${process.env.DATABASE_DIALECT}://${process.env.DATABASE_USERNAME}:${dbPassword}@${process.env.DATABASE_HOST}:${process.env.DATABASE_PORT}/${process.env.DATABASE_NAME}`,
    options: { ...databaseOptions },
  },
}];

but I want to create the DB connection by instanciate a Sequelize object and not by url (I did it for another project and that’s working well, but not working on forest API), is that possible? I’m working on Nodejs 12.

Thanks a lot guys!

  • Express Version: ^4.17.1
  • Sequelize Version: ~5.15.1
  • Database Dialect: Postgres

Hi @caid,

I assume you have a forest-cli generated (previously named lumber) project.

The file you shared looks to be config/database.js.
The Sequelize instanciation is done in models/index.js

Please let me know if this helps.
For further informations, please explain the cause of your needed changes. What do you need to do with Sequelize instance / instanciation?

Regards