Reputation: 1558
I am currently using GraphAware UUID Library to generate UUID in neo4j, later I found out that it has a randomUUID()
function to generate UUID, which one should be used?, will randomUUID()
create unique id on server?
Upvotes: 0
Views: 265
Reputation: 15086
They both call java.util.UUID#randomUUID()
, that's where the similarity between them ends.
The built-in Cypher's randomUUID()
is a function, which you have to call manually in each cypher query where you want to assign a UUID.
The neo4j-uuid
module is a set of extensions to Neo4j, which allow you to transparently assign UUID (or other types of ids - depending on configured id generator) to nodes and relationships, ensures the ids can't be changed or deleted. It also maintains an explicit index for the nodes / relationships. See the readme for the full feature set.
If your use case is simply to assign a uuid to (some) nodes or relationships then use the built in function. If you can take advantage of the other features of the neo4j-uuid module - use that.
Upvotes: 3
Reputation: 30407
For manual use cases, creating the UUID yourself in a Cypher query, they're functionally identical (GraphAware implemented this first I think, we got to it later). Yes the ids will be created on the server and will be unique, both
I believe GraphAware's UUID module covers more than just this, doing automatic assigning of UUIDs to newly created nodes and relationships and extra validation on top of that.
Upvotes: 1