DGraph-js,如何运行模式查询?

时间:2018-11-12 17:04:08

标签: node.js dgraph

我是Dgraph的新手,并且对dgraph-js的一个简单问题ash之以鼻。我什至仔细研究了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)上的自述文件仅提供了很多信息...

1 个答案:

答案 0 :(得分:2)