Loopback在哪里与子页面关联过滤与分页

问题描述 投票:1回答:1
-------------------
Schema Notification
-------------------
id,
userId,
status,
...


-----------
Schema User
-----------
id
name
email
...

我在loopback中有一个名为Notification的模型,它大致有id,userId,.....和其他一些字段。这里userId是与user表的关系,它有name和用户的其他细节。

What I have:在前端,我以分页形式显示所有这些通知(每页10条记录)。前端视图:

+------------------------------------------+
| UserName  UserEmail   NotificationStatus | 
+------------------------------------------+
| xxxx      [email protected]  PENDING            |
| xxxx      [email protected]  ACCEPTED           |
| xxxx      [email protected]  REJECTED           |
--------------------------------------------

What I want:能够根据用户关系中的名称搜索通知。

What I already know:是loopback已经提供了类似的东西:

include: [{
  relation:"user" ,
  scope:{ 
    where:{
      name: { like: 'name-of-user', options: 'i'} 
    }
  }
}]

What It returns:是所有通知,但仅包括名称与我传递的字符串匹配的用户。即打印所有通知,但留下与我传递的字符串不匹配的用户名和电子邮件。

What I thought to try:将删除我的角度前端控制器中的条目,这些条目在将http响应分配给遍历html中的条目的范围变量之前没有用户对象。但是,假设10个条目中有5个没有用户,angular会拼出这些条目,但实际上每页必须有10个条目,除非没有符合条件的记录。

我希望我有意义,并寻求解决这个问题。谢谢

pagination nested where relation loopback
1个回答
0
投票

如果您使用rdbms类型的模式,那么现在使用loopback是不可能的。看看一些未解决的问题。

https://github.com/strongloop/loopback/issues/517 https://github.com/strongloop/loopback/issues/683

您可能需要为此问题寻找本机sql

© www.soinside.com 2019 - 2024. All rights reserved.