This sounds silly but is there a way to create a empty array inside a Gremlin traversal?
For the query below:
g.V().has('person','name', 'marko').project('a', 'b').by().by()
I want to project b
as an empty array. I have tried:
g.V().has('person','name', 'marko').project('a', 'b').by().by(constant("").fold())
But constant("").fold()
is not actually empty constant("").fold().count()
returns 1. This applies to constant(null).fold()
as well.
Is this what you are looking for
g.withSideEffect('x',[]).V().has('person','name','marko').project('a','b').by(select('x')).by('name')
==>[a:[],b:marko]
An empty array/collection would actually be a fold()
of nothing. You'll get nothing if you filter everything, hence:
g.V().has('person','name','marko').
project('a', 'b').
by().
by(__.not(identity()).fold())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With