示波器返回列表中的loopback4过滤器仍在

发布于 2025-01-23 19:06:04 字数 498 浏览 2 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帝王念 2025-01-30 19:06:04

这是可以预期的,因为父母和关系查询应被视为两个单独的查询。

首先,解决了基于父母查询的教师列表。在查询学生列表时,解决的教师的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.

心作怪 2025-01-30 19:06:04

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文