node.js - DGraph-js,如何运行模式查询?
问题描述
我是 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 ) 上的自述文件只提供了这么多信息......
解决方案
you can use
res.getSchemaList();
As you can find in https://github.com/dgraph-io/dgraph-js/blob/18fa97c66bf9a2c897bf77ded119c1d1cb79333e/generated/api_pb.d.ts#L46
Cheers.
推荐阅读
- xcode - 如果在xcode中如何使语句改变值
- sql - 如何在 Vertica 中获取一个季度的第一天和最后一天
- sql - 使用模式或数组或其他任何东西在大查询中找到最适合的存储桶
- java - Spring在一个类中拦截异常
- reactjs - reactjs阿波罗反应取消请求
- snmp - 在 4.4.12 中使用 resolveWithMib 面临问题“TypeError:resolveWithMib() 恰好需要 2 个参数(3 个给定)”。它在 4.4.4 中工作
- java - 如何从 firebase 实时数据库中检索两个不同的值并在 onDataChange 方法之外使用?
- python - 处理内存中的大量文本数据
- php - 防止 div 从表 th 中的新行开始
- php - Carbon createFromFormat 错误 -> 数据丢失