MonkeyBonkey
MonkeyBonkey

Reputation: 47851

optimistic concurrency with neo4j using the REST API

Is there any way to implement optimistic concurrency during updating and creating neo4j nodes using the REST API? I'd like to create a user node with a unique name only if that name doesn't exist. Don't want two users to accidentally overwrite each other if they pick the same username at the same time.

Additionally, I'd could also have something like an incrementing version number to check for concurrency on the node. In SQL I would normally have an update with a where clause that checks for id and version number. Is there something similar I can do with cypher that would be easy to implment and wouldn't require me to type all the property names out into a long query?

Upvotes: 0

Views: 624

Answers (1)

Josh Adell
Josh Adell

Reputation: 1555

You could try a unique index: http://docs.neo4j.org/chunked/stable/rest-api-unique-indexes.html

Cypher "CREATE UNIQUE" syntax may also be a help: http://docs.neo4j.org/chunked/stable/query-create-unique.html

Upvotes: 2

Related Questions