node.js - 过滤器包括数据、Loopback、Mongodb、NodeJs
问题描述
created: "2021-07-19T07:20:28.742Z"
entity: "User"
entityId: "60f527bc517a22003f174ba1"
id: "60f527bc517a22003f174ba3"
user: {readOnly: {balance: 0, plan: "monthly", balanceExpireAt: "2021-08-
02T07:20:28.730Z",…},…}
filter: {
order: 'created DESC',
where: {
'user': {
exists: true // does not work!!
}
}, // or 'user': { 'orders': {gt: []} } also does not work (
include: {
relation: 'user',
scope: {
fields: ['email', 'id', 'readOnly'],
include: {
relation: 'orders',
scope: {
fields: ['id', 'info', 'settings'],
where: {
'or': [
{'notifications.telegram.enabled': true},
],
},
},
},
},
},
limit: this.limit,
skip: this.skip,
},
user
是我的查询中的嵌套数据,我无法以任何方式按用户对我的查询的顶层进行排序。例如,我想获取所有有书籍的用户的记录。但无论如何我都得到了所有的记录,只有当用户有书时,我才得到用户的记录,当没有书的书时,我得到没有用户的记录。我只需要过滤有书籍的用户的存在。用户的书也是一个嵌套记录。
解决方案
推荐阅读
- java - While循环中递减运算符的问题
- java - 耳机蓝牙超时,需要音频 ping
- reactjs - ReactJS:如何从输入字段的下拉列表中显示选定的值?
- node.js - 函数无法启动。Microsoft.Azure.DocumentDB.Core:必须为此操作提供 PartitionKey 值。?
- php - 500 错误“未捕获的错误:找不到类 '\XF\App'”
- powershell - Powershell - add duplicate key but different values into a hash table
- javascript - 当点彼此靠近时,谷歌地图标记聚类不打开
- flutter - 自定义侧边菜单显示/隐藏颤动
- c++ - C++ 卡验证问题
- jquery - 添加悬停:使用 jquery 之后?