Open Joshfindit opened 6 years ago
I would love to be able to use the built-in Neo4j ID for the id_property
. It would save a lot of code, but unfortunately the ID can be recycled and thus would cause problems for users of the gem.
We specifically avoided using something like a uuid
on relationships because Neo4j (the company via the design of the database) strongly discourages queries which start with relationships. All queries should start with nodes and use relationships to traverse to other nodes.
Does that make sense? I'm open to other suggestions
No, that definitely makes sense; the Neo4j ID is best considered transient. I'd much rather see the results with whatever permanent ID is used on the nodes.
The main problem this request is trying to solve is that the nodes do not return the Neo4j ID, and the relationships don't return any other ID. This means that the output of a raw query cannot be used to reconstruct the relationships.
Essentially;
This is not great but ok:
[{
"index": 0,
"n": {
"identity": {
"username": "Admin",
"public_name": null,
"staged": null,
"id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd",
"neo_id": "0"
}
},
"r": {
"id": 0,
"type": "AUTHORIZES_WEBSESSION",
"properties": {},
"start_node_id": 0,
"end_node_id": 2
},
"m": {
"web_session": {
"date_created": null,
"username": "Admin",
"id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
"neo_id": "2"
}
}
}]
This is better:
[{
"index": 0,
"n": {
"identity": {
"username": "Admin",
"public_name": null,
"staged": null,
"id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd"
}
},
"r": {
"id": 0,
"type": "AUTHORIZES_WEBSESSION",
"properties": {},
"start_node_id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd",
"end_node_id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
},
"m": {
"web_session": {
"date_created": null,
"username": "Admin",
"id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
}
}
}]
And this is no good:
[{
"index": 0,
"n": {
"identity": {
"username": "Admin",
"public_name": null,
"staged": null,
"id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd"
}
},
"r": {
"id": 0,
"type": "AUTHORIZES_WEBSESSION",
"properties": {},
"start_node_id": 0,
"end_node_id": 2
},
"m": {
"web_session": {
"date_created": null,
"username": "Admin",
"id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
}
}
}]
When querying directly with CYPHER, on a node type with an alternate ID (such as
UUID
) the node returnsuuid
by default, but the relationship returns the internal Neo4jID
.The request is: either have the node include the Neo4j
ID
, or (the better solution if we are looking to avoid referencing transient Neo4jID
s) have the relationship include the node's config-specifiedID
Code example (inline, gist, or repo)
Runtime information:
Neo4j database version:
3.1.1
neo4j
gem version:8.0.9
neo4j-core
gem version:7.0.6