Which method has neo4j.rb
to get value of <id>
field from Neo4j
database?
Asked
Active
Viewed 128 times
1
1 Answers
0
It depends what you mean ;)
The Neo4j.rb project has two main gems: neo4j
and neo4j-core
. If you're using the neo4j
gem to create ActiveNode
/ ActiveRel
objects in Neo4j, you can either use the node_object.id
/ node_object.uuid
methods to get the UUID generated by the gem or the node_object.neo_id
method to get the Neo ID generated by the database. The gem generates UUIDs because Neo4j internal IDs can be recycled and so don't offer the best option for external references to nodes. Keep in mind, though, that if you use the id_property
method in a model this will change the behavior of IDs generated by the gem.
The neo4j-core
gem allows you to make Cypher queries directly and from there you can get whatever you want. An example:
# Gets the Neo4j internal ID
Neo4j::Session.current.query("MATCH (n) WHERE n.name = 'Sue' RETURN ID(n)")

Brian Underwood
- 10,746
- 1
- 22
- 34
-
Thank you very much. It was very detailed and useful. – Dan Mukh Jun 06 '16 at 12:22