node.js - Association sequelize 3 tables, many to many -
i have 4 tables
- client - project - user - userproject one project belongs client , needs have client foreign key client_id.
userproject has project_id , user_id foreign keys, belongs project , user.
one user owns clients of projects.
- how can list clients of 1 user?
i'm wondering use eager loading feature sequalize:
client.findall({ include: [{ model: project, include: [{ model: user, where: { id: <userid> }, required: false }] }] }).then(function(clients) { /* ... */ });
Comments
Post a Comment