I want to create a neo4j
database with users. I want the following properties to be unique:
- username
- token
What I've tried:
CREATE CONSTRAINT ON (user:User) ASSERT user.username IS UNIQUE
CREATE CONSTRAINT ON (user:User) ASSERT user.email IS UNIQUE
CREATE CONSTRAINT ON (user:User) ASSERT user.token IS UNIQUE
However, this does not prevent me from creating new nodes with repeated email, username or token. The image shows 5 nodes, all with the same data but only the first one is a User. I don't want this, I want neo4j
to return an error.
Is it possible?
Thanks
EDIT:
Neo4j
version: 2.2.3
And I use neoism
for Go
to insert data:
n, err := db.CreateNode(neoism.Props{"id": user.Id, "username" : user.Username,
"displayname" : user.Displayname,
"email" : user.Email, "token" : user.Token})
if err != nil {
return ERROR_NEO4J
}
n.AddLabel("User")