Gremlin.createClient 不是 3.3.4 版本中的函数

标签 gremlin gremlin-server

Gremlin.createClient() 在版本 2.6.0 中工作,但在版本 3.3.4 中不起作用,我知道它从 3.3.4 开始已弃用。我想连接到服务器并执行查询。下面的代码是在2.6版本中执行。我想在 3.3.4 中执行相同的查询。

const Gremlin = require('gremlin');
const client = Gremlin.createClient(8182, 'localhost');
client.execute('g.V()', { }, (err, results) => {
  if (err) {
    return console.error(err)
  }

  console.log(results);
});

如何在 3.3.4 版本中写入?

最佳答案

如果可能的话,TinkerPop 不再建议使用脚本。最好用您选择的语言编写 Gremlin,对于您的情况是 Javascript:

const g = traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
g.V().hasLabel('person').values('name').toList()
  .then(names => console.log(names));

也就是说,您应该仍然可以通过这种方式提交脚本:

const gremlin = require('gremlin');
const client = new gremlin.driver.Client('ws://localhost:8182/gremlin', { traversalSource: 'g' });

const result1 = await client.submit('g.V(vid)', { vid: 1 });
const vertex = result1.first();

请查看完整reference documentation了解更多信息。

关于Gremlin.createClient 不是 3.3.4 版本中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56097422/

相关文章:

gremlin - 带有 id 的边已经存在 - Gremlin

Scala、gremlin-scala、HLists、Poly2、RightFold 和缺失的隐式 Prepend

amazon-web-services - Gremlin 到 AWS Neptune 的 403 禁止错误

c# - 小 Sprite 宇宙 : How to copy a property value of edge as vertex property inside a repeat command

Gremlin 查询以获取节点的边数和其他 V

solr - Janus Graph HBase 和 Solr 未知外部索引后端 : jgex

titan - 图遍历中的gremlin查询if-else-then

graph - 如何在 Gremlin Server Titan 1.0 中删除顶点

java - 在 Gremlin 3.2.5-SNAPSHOT 之后,我无法在函数 hasLabel() 中传递顶点标签数组

graph - 在 gremlin 查询中显示子级别