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

Gremlin.createClient不是版本3.3.4中的函数,gremlin,gremlin-server,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) =>

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();
有关更多信息,请参阅全文