【问题标题】:DGraph-js, how to run a schema query?DGraph-js,如何运行模式查询?
【发布时间】:2018-11-14 00:11:47
【问题描述】:

我是 Dgraph 的新手,我对 dgraph-js 的一个简单问题感到头疼。我什至仔细研究了 github 源代码,但我显然错过了我正在寻找的东西。

在 dgraph-ratel 界面中,我可以运行以下查询:

schema(pred: [name]) {
  type
  index
}

甚至只是

schema {}

获取有关数据库的架构信息。但是在 dgraph-js 中,如果我使用查询事务,它对于普通查询可以正常工作:

const res = await this.connection.newTxn().query(`query {
    getData(func: regexp(name, /.*mic+.*/i)) {
        name
    }
}`);
const data = res.getJson();

但运行以下:

const res = await this.connection.newTxn().query(`schema {}`);
const data = res.getJson();

返回一个空对象。我怀疑我不应该使用 newTxn().query() 而是其他东西。它应该是一个新的 dGraph.Operation() 吗?或者也许是别的什么?我在哪里可以看到我可以使用的所有功能? dgraph-js (https://github.com/dgraph-io/dgraph-js) 上的自述文件只提供了这么多信息...

【问题讨论】:

    标签: node.js dgraph


    【解决方案1】:

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 1970-01-01
    相关资源
    最近更新 更多