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

时间:2019-04-04 02:16:49

标签: dgraph

如果具有与用户架构(user_id)和发布架构(object_id)相关的架构“ Like”。如何查询具有user_id = (some_uid)object_id = (some_uid)的“赞”节点。

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

1 个答案:

答案 0 :(得分: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
    }
  }
}