Unable to add edge properties in Neptune/Gremlin?

335 Views Asked by At

I've been trying to add edges to existing vertices and give them a specific ID and some properties using the Gremlin library in nodeJS (connecting to an AWS Neptune graph) However, even though it seems as if the edges are created, the ID and properties were completely missed. Also I'll explain what I'm trying to achieve so the gremlin query will be clearer: Edges have 3 properties: Hidden, Directed, and ModificationDateTime.

  • look for an edge between pointA and pointB.
  • if such an edge exists and its ModificationDateTime is greater than our given "ignoreIfAboveDateTime", don't do anything.
  • else if such an edge exists and ModificationDAteTime is lower) then update its properties.
  • else if it doesn't exist, create it with the given ID and add the properties.

of course if there is a better way to do what I tried I would love to know and make it prettier!

I should mention that I am adding multiple edges with the same queries, meaning the following query is appended to itself (without the starting 'g') for each edge created.

`

g
  .V(`${pointA}`) // find the vertex with the given ID
  .bothE(`${label}`) // find all edges with the given label
  .where(__.otherV().hasId(`${pointB}`)) // find the edge with the given label that point to the given vertex
  .fold()
  .coalesce(
    __.unfold().where(__.values('ModificationDateTime').is(gt(`${ignoreIfAboveDateTime}`))), // if there is an edge with the given label that points to the given vertex, and the edge's ModificationDateTime is greater than the given ignoreIfAboveDateTime, then do nothing
    __.coalesce(
      __.unfold(), // the edge exists, so it will only be updated
      __.V(`${pointA}`).addE(`${label}`).to(__.V(`${pointB}`)).property(id, `${id}`) // the edge doesn't exist, so it will be created
    )
      .property('Hidden', `${hidden}`)
      .property('Directed', `${directed}`)
      .property('ModificationDateTime', `${modificationDateTime}`)
  )

`

When getting the edges the results are (for a single edge): { id:'82c27123-b690-296d-2266-24f377334c13' inV: v[056a3511-45ca-4e7c-838c-b144598ae0e54294967296] label: 'EdgesTestLabel123' outV: v[87fc214b-7066-460e-8660-c0ef19344a6b4294967296] properties: {} }

Will appreciate any tip regarding this, thanks! :)

1

There are 1 best solutions below

1
On

I made a stupid

It works just fine, I just assumed that the "properties" returned are the actual properties of the edge but they weren't. when I got the edges with valueMap() everything was there, oh well