graphaware / neo4j-uuid

GraphAware Runtime Module that assigns a UUID to all nodes (and relationships) in the graph transparently
103 stars 22 forks source link

How to get the last uuid #23

Closed lyamone closed 8 years ago

lyamone commented 8 years ago

Hi guys,

I need to know how to get the uuid of the last created node.

For instance, consider this cypher query which doesn't work as expected:

MATCH (source:User {id:1}),(target:User {id:2}) CREATE (source)-[rel:FOLLOWS]->(target) Return rel.uuid

Is there a way to have the uuid of the relationship?

Thanks in advance! Lucas.

ikwattro commented 8 years ago

Hi,

It is not possible to get the uuid at creation time simply because there is no possibility to add additional information from a module to a Cypher result.

What you can do is return the id of the relationship and performs an additional query :

Query1

MATCH (source:User {id:1}),(target:User {id:2})
CREATE (source)-[rel:FOLLOWS]->(target)
Return id(rel) as relId

Query2

MATCH ()-[r]-()
WHERE id(r) = {relId}
RETURN r.uuid as uuid
lyamone commented 8 years ago

Thanks! I had thought of the same solution but I didn't know if there was a better way to do it considering the volatility of the neo4j id's.