I defined 2 connections in the /config/connections.js file:
monolithMysql: { user: 'store_app', database: 'store', dialect: 'mysql', options: { dialect: 'mysql', host: 'dockerhost', port: 3306, logging: console.log } }, postgres: { user: 'user_app', database: 'user_authentication', dialect: 'postgres', options: { dialect: 'postgres', host: 'dockerhost', port: 8201, logging: console.log } }
and in different models I put the connection property so that they differ as follows:
module.exports = { options: { connection: 'monolithMysql', // or 'postgres' in other models. ...
In /config/models.js I set the default connection monolithMysql . But this should be overridden by the connection property, if specified, in models. If I comment or do not specify the connection property in /config/models.js , then the bootloader with the Sequelize label cannot be loaded.
However, when trying to query models having postgres as the connection, it still queries them in the MySQL database and fails ... If I set postgres as the default connection, then it will always query in this database, regardless of what the local connection property says for different models.
Any suggestions for setting up two connections at the same time?
Update: it turned out that it initializes only 1 instance of Sequelize - the instance with the default connection specified in /config/models.js