Gremlin.createClient() is working in version 2.6.0 but it is not working in version 3.3.4,I know it is deprecated from 3.3.4.I want to connect to server and execute query.The below code is executed in version 2.6. I want to excute same query in 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);
});

How can i wirte in version 3.3.4?.

1 Answers

0
stephen mallette On

TinkerPop no longer recommends the use of scripts if possible. It is best to simply write Gremlin in the language of your choosing, which for your case is Javascript:

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

That said, you should be able to still submit scripts this way:

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();

Please see the full reference documentation for more information.