I defined 3 models in Loopback: job
, contact
and job_contact
(through model) and using hasManyThrough
relations defined below relation:
job
has manycontact
throughjob_contact
.
and I used the code below to find contacts
by job
through job_contact
job.findById(id, {
include: {
relation:'contact',
where :{deleted: false}, // no working here
scope:{
where:{deleted: false} // here will add condition on contact table
}
}
})
Someone got any ideas? How can I put conditions on "through" model, job_contact
model, in this case?
I have found it is not possible to interact with the through model with filters on queries the two other models. If you want to access the through model you need to query it independently.
See part More Info at the bottom of the answer here and the linked github discussion.