thorOdinson
thorOdinson
ATApache TinkerPop
Created by thorOdinson on 3/5/2025 in #questions
MergeE with a conditional on the value being set
I'm trying to use MergeE to create an edge if it does not exist (based on the label and in/out nodes) and if it does exist I want to update a modified timestamp on the edge only if the incoming timestamp is greater than what is on the edge, so far I've got something like:
g.mergeE([
(T.label): 'RUNS',
(to): 'nodeID',
(from): 'nodeID'
]).
option(onCreate, [
(from): 'nodeID',
(to): 'nodeID',
(T.id): 'someUUID',
'modifiedTime': 'Wed Mar 05 12:15:39 EST 2025'
]
).
option(onMatch, __.filter(__.coalesce(
__.values("modifiedTime").is(lt('Wed Mar 05 12:15:39 EST 2025')),
__.constant(true))).
property("modifiedTime", 'Wed Mar 05 12:15:39 EST 2025')).
next()
g.mergeE([
(T.label): 'RUNS',
(to): 'nodeID',
(from): 'nodeID'
]).
option(onCreate, [
(from): 'nodeID',
(to): 'nodeID',
(T.id): 'someUUID',
'modifiedTime': 'Wed Mar 05 12:15:39 EST 2025'
]
).
option(onMatch, __.filter(__.coalesce(
__.values("modifiedTime").is(lt('Wed Mar 05 12:15:39 EST 2025')),
__.constant(true))).
property("modifiedTime", 'Wed Mar 05 12:15:39 EST 2025')).
next()
but I can't seem to figure out what should be going into the onMatch section to get this to work
6 replies