graph
graph copied to clipboard
Add an example of using coalesce() inside a by() modulator.
Should add an example that shows that this is possible
gremlin> g.V(0,3).project('city').by(coalesce(values('city'),constant('not found')))
==>[city:not found]
==>[city:Austin]
I have another usage for coalesce that will be useful for 'upsert', in python:
airport_code = 'HLO'
airport_description = 'World'
t = (g.V()
.has('airport', 'code', airport_code)
.fold() # "None" is folded if not found
.coalesce(
unfold(), # if "None" is unfolded the 'else' part of coalesce step is taken
g.addV('airport')
.property('code', airport_code)
)
.property('description', airport_description)
# ...
)
assert next(t, None)
As part of the changes to address this issue, we should also discuss the changes to the way "non productive" by modulators now act as filters in Gremlin post 3.6.0.