Вы можете просто установить несколько соединений Sequelize в вашем databaseProviders
:
export const databaseProviders = [
{
provide: 'SequelizeCatToken',
useFactory: async () => {
const sequelize = new Sequelize({
dialect: 'mysql',
host: 'localhost',
port: 3306,
username: 'catroot',
password: 'catpassword',
database: 'cats',
});
sequelize.addModels([Cat]);
await sequelize.sync();
return sequelize;
},
},
{
provide: 'SequelizeDogToken',
useFactory: async () => {
const sequelize = new Sequelize({
dialect: 'mysql',
host: 'localhost',
port: 3306,
username: 'doogroot',
password: 'dogpassword',
database: 'dogs',
});
sequelize.addModels([Dog]);
await sequelize.sync();
return sequelize;
},
},
];