I am trying to create node but with unique specific property to get the node by this property , knowing that this property is the name in my project nodes , please anyone explains how neo4j handles the uniqueness
Hi Omar, you can create a uniqueness constraint in your graph, which dictates that a specific property on a specific label will have a unique value in your graph.
CREATE CONSTRAINT YourUniqueConstraint IF NOT EXISTS
FOR (x:YourLabel)
REQUIRE x.name IS UNIQUE
With this you would be able to create a node (:YourLabel {name: 'myname'}) once, if another node with the label :YourLabel and the value 'myname' tries to get created, neo4j will reject this attempt and throw an error.
Furthermore adding the constraint is automatically creating an index for this label and property, so finding a node with a specified name will be able to use an index for faster lookup.
--duplicate--
(migrated from khoros post Re: unique property - Neo4j - 59160)
I recommend that you go through our newest course which teaches about uniqueness constraints in Neo4j.
https://graphacademy.neo4j.com/courses/cypher-indexes-constraints/
Elaine