addConstraint: Uniqueness Constraints

Description Usage Arguments Details See Also Examples

Description

Add a uniqueness constraint to a label and property key.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)

nicolewhite/RNeo4j documentation built on May 23, 2019, 5:09 p.m.