I have been trying to make gremlin work with nodejs. I found out that i could use one of the gremlin driver gremlin-javascript to achieve this. A quick workable script is as follow:
const gremlin = require('gremlin');
const Graph = gremlin.structure.Graph;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const graph = new Graph();
const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { traversalSource: 'g' }));
const addUser1 = async () => {
const newVertex = await g.addV("id", 1, "label", "person", "name", "marko", "age", 29)
console.log("Vertex added: ", newVertex)
}
const traverse = async () => {
const traverse = await g.V().has("name", "marko")
console.log(traverse)
}
addUser1()
traverse()
Now running this script returns me a Pending Promise of some sort. And I don't need that. What I really need are the nodes not some form of object. Result for addUser1() is given as follows:
Promise {
<pending>,
domain:
Domain {
domain: null,
_events: { error: [Function: debugDomainError] },
_eventsCount: 1,
_maxListeners: undefined,
members: [ [Object] ] } }
> Vertex added: GraphTraversal {
graph: Graph {},
traversalStrategies: TraversalStrategies { strategies: [ [Object] ] },
bytecode: Bytecode { sourceInstructions: [], stepInstructions: [ [Array] ] },
traversers: null,
sideEffects: null,
_traversalStrategiesPromise: null,
_traversersIteratorIndex: 0 }
And for the traverse():
Promise {
<pending>,
domain:
Domain {
domain: null,
_events: { error: [Function: debugDomainError] },
_eventsCount: 1,
_maxListeners: undefined,
members: [ [Object] ] } }
> GraphTraversal {
graph: Graph {},
traversalStrategies: TraversalStrategies { strategies: [ [Object] ] },
bytecode:
Bytecode {
sourceInstructions: [],
stepInstructions: [ [Array], [Array] ] },
traversers: null,
sideEffects: null,
_traversalStrategiesPromise: null,
_traversersIteratorIndex: 0 }
I don't really understand the problem actually. Isn't there a comprehensive guide that could show a simple working example. Your help in making me understand the issue would be highly appreciated.