DEV Community

Mohd Taqi
Mohd Taqi

Posted on

how to Define belongsTo relation between the tables of different databases using Sequelize ORM

I tried this syntax but it failed with error foreign key constrain is incorrectly formatted

const DB = {};

const conn = mysql.createConnection({
host: dbConfig.HOST,
user: dbConfig.USER,
password: dbConfig.PASSWORD,
port: dbConfig.PORT,
});

DB.Sequelize = Sequelize;

DB[userDB].design.belongsTo(DB[masterDB].stone_master);

Can anyone please help me on this

Is this possible with sequelize?

Is there any workaround to achieve this?

Environment

  • 1. Mysql2 Version: ^2.1.0
  • 2. Sequelize Version: ^5.21.3
  • 3. Node version: v14.17.6

Top comments (0)