DGraph-js,如何 运行 模式查询?
DGraph-js, how to run a schema query?
我是 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();
returns 一个空对象。我怀疑我不应该使用 newTxn().query() 而是其他东西。它应该是一个新的 dGraph.Operation() 吗?还是别的什么?我在哪里可以看到我可以使用的所有功能? dgraph-js (https://github.com/dgraph-io/dgraph-js) 上的自述文件只提供了这么多信息...
你可以使用
res.getSchemaList();
中找到
干杯。
我是 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();
returns 一个空对象。我怀疑我不应该使用 newTxn().query() 而是其他东西。它应该是一个新的 dGraph.Operation() 吗?还是别的什么?我在哪里可以看到我可以使用的所有功能? dgraph-js (https://github.com/dgraph-io/dgraph-js) 上的自述文件只提供了这么多信息...
你可以使用
res.getSchemaList();
中找到
干杯。