brikteknologier / seraph

A thin and familiar layer between node and neo4j's REST api.
MIT License
309 stars 59 forks source link

Node Id is overwritten by seraph #205

Closed jhillhouse92 closed 7 years ago

jhillhouse92 commented 8 years ago

I had a property on a node, (r:Report {id: '233sDfdfsdf3'}), that when fetched with seraph (even with just db.query), seraph overwrote the node id property. It should check if the node contains that property and if so, not to overwrite it with ID(node).

alex-alfaro commented 8 years ago

Seraph always returns the ID(node) along with nodes, the property is by default called 'id'. This is due to the fact that Seraph relies on the internal Neo4j id system to perform node updates (which is by the way not 100% safe see: http://stackoverflow.com/questions/30753560/should-we-use-the-neo4j-internal-id).

The solution is to rename seraph's identifier in the options argument when you initialize your client (https://github.com/brikteknologier/seraph#seraph), so if you name it 'seraph_id' it won't touch/replace your own logic Ids.

markmssd commented 7 years ago

Hey @alex-alfaro,

You're right about renaming the id option, in which case Seraph will not touch/replace it. But Seraph should not rely on the internal id to perform node updates neither, as per your SO link, and as per their blog post: https://neo4j.com/blog/dark-side-neo4j-worst-practices.

Seraph should instead accept a function for the id field, e.g. { id: uuid() }, and use it to generate IDs, iff the id is not specified.

In other words, it should work in a similar way as this Java package: https://github.com/graphaware/neo4j-uuid.