Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get or create? #164

Open
triptec opened this issue Jul 25, 2016 · 1 comment
Open

how to get or create? #164

triptec opened this issue Jul 25, 2016 · 1 comment

Comments

@triptec
Copy link

triptec commented Jul 25, 2016

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() }
}

@mpollmeier
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants