all examples for mergeV/mergeE seem to be groovy but it's not obvious how to translate them to javascript. I got as far as this:
const { onCreate, onMatch } = gremlin.process.merge;
const { from_, to } = gremlin.process.direction;
this
.mergeE(to, tgt.id)
.option(onCreate, { created: now, updated: now })
.option(onMatch, { updated: now })
but the mergeE instruction generates an error.
I tried:
.mergeE([to, tgt.id])
with the effect: "Could not locate exact method given the supplied arguments: NeptuneGraphTraversal.mergeE(ArrayList)".mergeE(to, tgt.id)
Could not locate exact method given the supplied arguments.mergeE({ [to.toString()]: tgt.id, [from_.toString()]: this.id })
an unexpected error has occured in Neptune; obviously we cannot do [to]: tgt.id in jsIf anyone has a clear example for mergeE in javascript/typescript, it would help immensely. I'm asking specifically in the Amazon Neptune context but hopefully it can be useful for other cases as well. Even better would be to have a side-by side example for mergeV, but maybe a lot to ask.
Thank you
Here is an example translation of what I believe you are trying to accomplish:
const gremlin = require('gremlin');
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const direction = gremlin.process.direction
const t = gremlin.process.t
const { onCreate, onMatch } = gremlin.process.merge;
const g = traversal().withRemote(new DriverRemoteConnection('wss://<CLUSTER ENDPOINT>:8182/gremlin'));
g.
mergeE(new Map([[t.label,"Test"],
[direction.out,'1'],[direction.in,'2']])).
option(onCreate,new Map([["created",Date.now()]])).
option(onMatch,new Map([["updated",Date.now()]])).elementMap().toList().then(data => console.log(data))