Different Sequelize.js and MySQL association model schemas

I have two MYSQL schemas and they should work together.

IE: the "user" table is in the "a" schema, and the "profile" table is in the "b" schema.

  • Profile → has many users

  • Users → Belong to Profile

Can you define associations between both models that live in different schemes this way in Sequelize js?

// after define the models .. Profile.hasMany(User); User.belongsTo(Profile); // get the profile of the user(from the b schema) User.find(1).success( function(user) { console.log(user.getProfile()); }); 

Will this work?

How should I define models from different schemas?

+5
source share

Source: https://habr.com/ru/post/1201386/


All Articles