RNeo4j (version 1.6.4)

addConstraint: Uniqueness Constraints

Description

Add a uniqueness constraint to a label and property key.

Usage

addConstraint(graph, label, key)

Arguments

graph
A graph object.
label
A character string.
key
A character string.

Details

A uniqueness constraint cannot be added to a (label, key) pair that already has an index applied. Attempting to add a uniqueness constraint where an index already exists results in an error. Use getIndex to view any pre-existing indexes. If you wish to add a uniqueness constraint, use dropIndex to drop the index.

See Also

getConstraint, dropConstraint

Examples

Run this code
## Not run: 
# graph = startGraph("http://localhost:7474/db/data/")
# clear(graph)
# 
# addConstraint(graph, "Person", "name")
# 
# createNode(graph, "Person", name = "Alice")
# createNode(graph, "Person", name = "Bob")
# try(createNode(graph, "Person", name = "Alice"))
# ## End(Not run)

Run the code above in your browser using DataLab