node.js - 无法使用 dgraph-orm 查询嵌套关系

标签 node.js orm graph-databases dgraph

我正在使用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。

感谢您提出问题。

关于node.js - 无法使用 dgraph-orm 查询嵌套关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58074943/

相关文章:

node.js - 上传图片时 Nodejs 内存填得太快~10MB

javascript - 如何在 Sequelize 中创建关联

JavaScript 从文件中读取

orm - 为什么使用数据库迁移而不是版本控制模式

nosql - OrientDB 是否允许一个或多个顶点有多个边?

neo4j - 优化 Cypher 查询 Neo4j

node.js - 尝试代理到 : localhost:3000/api/graphql 时发生错误

Symfony2/Doctrine2 刷新实体管理器时抛出索引错误

django - 返回模型常见查询的最 Django 式方式

neo4j - 使用导入工具将 TSV 数据导入 Neo4j