gremlin-scala
gremlin-scala copied to clipboard
how to get or create?
How would you do something simple like this? Would be nice to have it in the readme
getOrCreate = { type, id ->
g.V().hasLabel(type).hasId(id).tryNext().orElseGet{ g.addV(T.id, id, T.label, type).next() }
}
that should work, however I'm not really a fan of specifying the id... IMHO that should be left to the database. not sure if it's common enough to have it in the readme on the front page, but a test (e.g. in ElementSpec) would be great - fancy creating a quick PR?