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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -