Not sure if I'm just being silly, but encountered something that's stumped me with regards to Sequelize.
Preamble
Let's say you have Users and Projects like the examples the Sequelize site provides, to keep things simple.
With a n:m relationship for this example, one User can be assigned to multiple Projects, and visa versa.
With relationships correctly set up, you should be able to call the following:
//To get the projects a user is assigned to:
user.getProjects();
//To get the users assigned to a project:
project.getUsers();
The Issue
While this is pretty handy already, how to I access the 'inverse' relationship, for instance Users NOT assigned to a Project, or Projects a User IS NOT a part of?
Would this be achieved via a scope, or can it be achieved with the creation of another relationship?
Kind regards :)
via N15M0_jk
No comments:
Post a Comment