Search code examples
graph-theorygremlintinkerpop3gremlin-serveramazon-neptune

gremlin javascript can't collect the properties of a vertex


After inserting a vertex in amazon neptune , I get the an unique id . If I want to print out the properties of a vertex , I can do it easily in gremlin console

enter image description here

But in my node js app , if I try to do the same I can't get the properties of the vertex

Here is what I have done in javascript

const fetchPropertyByVertexId = async (vertexId) => {
  console.log("requsting properties of vertex "+vertexId);
  return await g.V(vertexId).properties();
}

and then , I call

   fetchPropertyByVertexId(vertexId).then( property =>{
     console.log(property);
   });

And the output is

enter image description here

I am using this library to connect with amazon neptune . How can I get property of a vertex , in key value pair , like I get it in gremlin console ?


Solution

  • I think that you need to iterate your traversal. This:

    return await g.V(vertexId).properties();
    

    returns a Traversal object which does not return results - it just represents the object to iterate to get results. So, you need to include a terminal step like toList():

    return await g.V(vertexId).properties().toList();