查询节点,使用子节点的 uid 进行过滤(关系)

Query for a node, filtering using uid of child nodes (relations)

如果有一个架构 "Like" 与用户架构 (user_id) 和 Post 架构 (object_id) 有关系。如何查询具有 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

试试这个

{
  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
    }
  }
}