Prabjot Singh
Prabjot Singh

Reputation: 4767

Create unique relationship in neo4j

I want to create unique relationship in neo4j. My requirement is , i have a common resource for all nodes, so if node A is using it, then node B cannot use it, means cannot create relationship of B with resource. So how can i do this ?

Upvotes: 0

Views: 520

Answers (1)

Brian Underwood
Brian Underwood

Reputation: 10856

I'm pretty sure at the moment you can't have neo4j enforce for you. I think you would need to check whenever you try to add the relationship. Here's an example in cypher, though if you're using java you might be using a lower level API:

MATCH (a:LabelA {id: '123abc'), (res:Resource {id: '321cba'})
  WHERE NOT(()-[:has_resource]->res)
  CREATE a-[:has_resource]->res

Upvotes: 2

Related Questions