brikteknologier / seraph

A thin and familiar layer between node and neo4j's REST api.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node Id is overwritten by seraph

jhillhouse92 opened this issue · comments

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).

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.

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.