-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Here is the test project: https://github.com/geekguy/loopback-sandbox (Details in readme)
Lets say we have 3 models, M1, M2 and M3 and instances are m1, m2 and m3.
M1 hasMany M2 and M2 hasMany M3.
Now. I want M2s for a given M1 and I want to include M3 with some condition.
m1.m2s({
include: [
{
relation: 'm3s',
scope: {
where: {
someCondition: something
}
}
}
]
})
This returns all m2s and includes m3s with matching condition which is perfect.
Now I wan only one m3 per m2. So I ll add limit: 1
m1.m2s({
include: [
{
relation: 'm3s',
scope: {
where: {
someCondition: something,
limit: 1
}
}
}
]
})
But this call has some issues. It returns 1 m3 for first m2 and 0 for rest of them.
If I change limit: 2, it returns 1 m3 for first two m2 and 0 for rest of them.
Looks like scope condition is going wrong.
Please correct me if I missed anything or doing something wrong.