Domanda

EDIT

When i am talking about node and node id i am specifically talking about the Neo4j representation of a node not node as in Node.js


I am building out an application on top of Neo with node using the thingdom wrapper on top of the REST API and i am attempting to add my own custom id property that will be a hash of the id to be used in the URL for example.

What i am currently doing is creating the node and then once the id is returned hashing this and saving it back to the node, so in effect i am calling the REST API twice to create a single node.

This is a long shot but is there a way to get a reliable next id from Neo using the REST API so that i can do this all in one request.

If not does anyone know of a better approach to what i am doing?

È stato utile?

Soluzione

The internal id of neo4j nodes is not supposed to be used for external interfaces, as noted in the documentation. That means especially it's not a good idea to try to guess the next id.

It's recommended to use application specific ids to reference nodes, if you use UUIDs (especially uuid type 4) there is only a minimal chance of collisions and you can compute them on node creation, before storing them in the database.

Altri suggerimenti

By curiosity, can I ask you why you need to have the Id stored in the Node?

But anyway, it's quite common in Node.js to call a succession of APIs. And you will see that with Neo4j it will be required more than once.

If you don't already use it, I can only suggest you to take a look at Async: https://github.com/caolan/async

And particularly to the "waterfall" method that allows you to call more than one API that use the result of the previous call.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top