示波器返回列表中的loopback4过滤器仍在
我正在使用LB4 我在这里遇到了一些问题,我尝试找到列表,其中范围内的条件与分页。
const teacherWithStudents = await this.teacherRepository.find({limit:10,skip:0,
include: [{
relation: "student",
scope: {
where: { "name": "some random name here" },
}
}]
})
预期的老师的数组是:[](因为我搜索了一个不在db中的学生名称中的随机字符串),
但是我没有这样的学生让老师去阵列:[{{contercyid:1,thockername:stella'} 2,Teachername:“ Mery”}]
如果我过滤了学生的名字,如果没有老师有一个我过滤的学生,我需要一个空数组,但我只有一名老师。
我希望我能详细解释这个问题。 提前致谢
I'm using lb4
I have some problems here, I try to find the list with where conditions inside the scope with pagination.
const teacherWithStudents = await this.teacherRepository.find({limit:10,skip:0,
include: [{
relation: "student",
scope: {
where: { "name": "some random name here" },
}
}]
})
The expected teacher's array is : [] (because I searched a random string in student name which is not in DB)
but I got teachers to array without student like this: [{teacherId:1,teacherName:"Stella"}{teacherId:2,teacherName:"Mery"}]
if I filter student names if no teacher has a student that I filtered I need an empty array but I get only a teacher.
I hope I explained the issue in detail.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是可以预期的,因为父母和关系查询应被视为两个单独的查询。
首先,解决了基于父母查询的教师列表。在查询学生列表时,解决的教师的ID随后用作约束。
然后将两个结果组合在一起以创建最终响应。
This is expected as the parent and relation queries should be perceived as two separate queries.
First, the list of teachers based on the parent query are resolved. The IDs of the resolved teachers are then used as a constraint when querying for the list of students.
Both results are then combined together to create the final response.
LOOPBACK使用左JOIN。如果您只想找到学生不为null的老师,则必须使用本机查询的内在加入。
Loopback uses left join. if you want to find only teachers where student is not null then you have to use inner join with native query.