Is there a way to do the below use case in our single query.
Currently, we are doing the above using two queries.
You shouldn't have to do anything special if your only choice is to proceed if the element exists. In other words, if you have:
g.V(1).out()
If a vertex with id
of "1" is not present, it will simply not traverse out()
as none exists. If you have a need for alternative processing in the event that the vertex does NOT exist then you will need to use some form of branching logic (typically coalesce()
or choose()
). Here's some examples of element existence checks which demonstrate "get or create" types of operations that might be applicable to what you're doing.