首页 > 解决方案 > 如何让 Dgraph uid_in 使用变量输入

问题描述

我试图将我的数据库引擎更改为 DGraph。我真的需要更改我的应用程序以使用 uid 而不是使用我当前的 ID。我需要使用多个 uid_in 用法进行过滤,目前我的应用程序通过 ID 属性执行此操作。但看起来我不能使用我需要使用 uid 的 ID 属性。但是看起来当你使用 uid_in 函数时你不能使用变量。执行以下操作的最有效方法是什么:

{
        SQ (func: eq(id, 10000))   {
            dgraph.type
            F as uid    
        }

  {
        Q2(func: has(id)) @filter(uid_in(edgefield, F))  {
            dgraph.type
            uid
        id
            expand(_all_) {
                id
          uid
        dgraph.type
            }
        }
    }
    }

标签: dgraph

解决方案


现在 Dgraph 最新版本 (20.07.X) 支持变量中的 uid 映射。例如:

@filter(uid_in(edgefield, uid(F)))

https://github.com/dgraph-io/dgraph/pull/5320


推荐阅读