node.js - 无法使用 dgraph-orm 查询嵌套关系
问题描述
我正在使用dgraph-orm 来获取嵌套的关系值,但它适用于单级而不是多级。我正在获取页面详细信息,但无法获取页面的头像。
这是我的片段:
let posts = await PagePost.has('page_id', {
filter: {
page_id: {
uid_in: [page_id]
}
},
include: {
page_id: {
as: 'page',
include: {
avatar: {
as: 'avatar'
}
}
},
owner_id: {
as: 'postedBy'
}
},
order: [], // accepts order like the above example
first: perPage, // accepts first
offset: offset, // accepts offset
});
我没有得到属性 page_id 的头像:
{
"uid": "0x75b4",
"title": "",
"content": "haha",
"created_at": "2019-09-23T08:50:52.957Z",
"status": true,
"page": [
{
"uid": "0x75ac",
"name": "Saregamaapaaaa...",
"description": "This a is place where you can listen ti thrilling music.",
"created_at": "2019-09-23T06:46:50.756Z",
"status": true
}
],
"postedBy": [
{
"uid": "0x3",
"first_name": "Mohit",
"last_name": "Talwar",
"created_at": "2019-07-11T11:37:33.853Z",
"status": true
}
]
}
orm中是否支持多级字段查询?
解决方案
ORM 本身存在一些问题,它无法识别多级包含的正确模型名称并生成错误的查询。
在 1.2.4 版本中修复了相同的问题,请运行npm update dgraph-orm --save
以更新您的 DgraphORM。
谢谢你的问题。
推荐阅读
- python - 如何创建具有相同类型成员的静态类型 python 类
- cucumber - 黄瓜重新运行失败的测试 java jenkins
- android - Android 中的 Fontawesome 5,3 个文件
- c# - 实体框架 6 System.Threading.ThreadAbortException
- google-apps-script - 是否可以记录谁在 Google Drive 中打开文件
- kubernetes - k8s 容器和主机上的最大用户进程数
- android - Android Studio 模拟器:进程以退出代码 13 完成
- r - R中实际计算时间与预期时间之间的差距
- java - 如何生成地雷,但不在 Java Minesweeper 克隆中发现它们
- excel - 工具库存列表的搜索框功能