Correct Javascript syntax for MergeV and MergeE

58 views
Skip to first unread message

Stephen Akaeze

unread,
Apr 21, 2023, 2:27:30 AM4/21/23
to Gremlin-users
Hi Everyone,

I need some help regarding the MergeV and MergeE syntax in Javascript. The documentation syntax shows the following example from the TinkerPop groovy documentation,

 g.mergeV([(T.label):'Dog', name:'Max'])
option.Merge.onCreate,[(T.label):'Dog', name:'Toby']

However, the map (containing the T.label and name keys) syntax per groovy is array syntax in Javascript. My question is as follows; how do you correctly rewrite the above expressions using the Javascript GLV? 

Stephen Mallette

unread,
Apr 25, 2023, 7:05:00 PM4/25/23
to gremli...@googlegroups.com
You just need to use a javascript Map (i think object syntax works as well):

g.mergeV(new Map([[T.label,"Dog"],["name","Max"]])).option(Merge.onCreate,new Map([[T.label,"Dog"],["name","Toby"]]))

it was neat to answer this question by using Dave Bechberger's new Gremlin translation tool:



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/a2cb77c5-cd55-495c-99fc-32e984ef5ee7n%40googlegroups.com.

Stephen Akaeze

unread,
Apr 26, 2023, 3:21:12 AM4/26/23
to Gremlin-users
Thanks a lot Stephen!
Reply all
Reply to author
Forward
0 new messages