【问题标题】:Query for a node, filtering using uid of child nodes (relations)查询节点,使用子节点(关系)的 uid 进行过滤
【发布时间】:2023-03-09 12:15:01
【问题描述】:

如果有一个与用户模式 ​​(user_id) 和发布模式 (object_id) 有关系的模式“Like”。如何查询具有user_id = (some_uid)object_id = (some_uid) 的“Like”节点。

我正在使用dgraph-io/dgraph-js

User Schema               Post Schema             Like Schema

uid                       uid                     uid
first_name                type                    object_id (maps post)
last_name                 content                 user_id (maps user)
email                     title
created_at

【问题讨论】:

    标签: dgraph


    【解决方案1】:

    试试这个

    {
      likes(func: has(like.object_id)) @filter(uid_in(like.object_id, 0x2) and uid_in(like.user_id, 0x3)){
        like.object_id {
          uid
          post.type
          post.content
          post.title
        }
        like.user_id{
          uid
          user.email
          user.first_name
          user.last_name
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多