I've had a few on and off discussions with a few people here, so I wanted
to send this out to everyone for feedback.

What are people's thoughts on creating a new set of steps that codify
common Gremlin best practices?

I think there are several common Gremlin patterns where users would benefit
from the additional guidance that these codified steps represent.  The
first one I would recommend though is codifying the element existence
pattern into a single Gremlin step, something like:

mergeV(String, Map, Map)
     String - The vertex label
     Map (first) - The properties to match existing vertices on
     Map (second) - Any additional properties to set if a new vertex is
created (optional)
mergeE(String, Map, Map)
     String - The edge label
     Map (first) - The properties to match existing edge on
     Map (second) - Any additional properties to set if a new edge is
created (optional)

In each of these cases these steps would perform the same upsert
functionality as the element existence pattern.

Example:

g.V().has('person','name','stephen').
           fold().
           coalesce(unfold(),
                    addV('person').
                      property('name','stephen').
                      property('age',34))

would become:

g.mergeV('person', {'name': 'stephen'}, {'age', 34})

I think that this change would be a good addition to the language for
several reasons:

* This codifies the best practice for a specific action/recipe, which
reduces the chance that someone uses the pattern incorrectly
* Most complex Gremlin traversals are verbose.  Reducing the amount of code
that needs to be written and maintained allows for a better developer
experience.
* It will lower the bar of entry for a developer by making these actions
more discoverable.  The more we can help bring these patterns to the
forefront of the language via these pattern/meta steps the more we guide
users towards writing better Gremlin faster
* This allows DB vendors to optimize for this pattern

I know that this would likely be the first step in Gremlin that codifies a
pattern, so I'd like to get other's thoughts on this?

Dave

Reply via email to