problem description
as mentioned, when egg-Sequelize has no foreign key relationship (created with reference), it is not possible to query data related to multiple tables using include. Also ask the gods to advise
or after using association, you can bypass this problem without generating foreign keys when using sync to create a database.
the environmental background of the problems and what methods you have tried
- Thank you for the article related API documents , keyword search (" unconstrained foreign key references ") to learn that using reference can avoid creating foreign key relationships, try to use app.sync to generate libraries, find no relationship, project rerun, and find that you still need to point to the relationship chain between Model, .
- if you use association, instead of reference, the database foreign key will be created. No, no, no.
related codes
/app/model/user.js
...
User.associate = () =>{
User.hasMany(app.model.UserRole); // reference
}
...
what result do you expect? What is the error message actually seen?
using sync to generate a database does not generate foreign keys and can include multiple model queries when it can be queried.
Thank you!