Closed brunocascio closed 9 years ago
Hey @brunocascio,
Cypher queries, by their design, are meant to always return "rows" of results. Each "row" is a dictionary of variable name to value. Because of this, the query
method always returns an array of dictionaries.
In this case, your query ends with RETURN recipe
, so the dictionary for each row will have a recipe
key. (We can only go by the name in your query, i.e. recipe
; we can't guess a plural recipes
.)
So instead of the return value from query
looking like {recipes: [{...}, ...]}
, it looks like [{recipe: {...}}, ...]
.
If you're referring to the object data for each recipe
node, don't worry about all of the stuff within _data
(note underscore prefix) — that's an internal/private property needed by node-neo4j.
Your properties (name
and id
) are within the public data
(no underscore prefix) property.
That said, this is getting improved a bit in node-neo4j v2 if you want to try that out. See the note in the current readme for details.
Hope this helps!
Worth clarifying one thing: by id
are you referring to the native Neo4j ID? Or your own custom id
property? My response above assumed it was a custom property.
If native Neo4j ID, that's actually the id
property on the returned node object directly, not under data
. (In v2, it's named _id
to reflect that its use has been discouraged by the Neo4j team.)
Thanks for response! :)
I understand. I think to return all these data, is too much. It generate confuses JSON responses and your size is potentially big!
Anyway, thanks :+1:
And yes, id
is a custom ID.
I changed to branch v2, and the response is much comfortable.
Thanks @aseemk !
I get this query:
'MATCH (user:User)', 'WHERE ID(user) = {id}', 'MATCH (user)-[rel:PREPARE]->(recipe)', 'RETURN recipe',
Result:
is possible return response like:
{recipes:[ { name: 'recipe name', id: 1 } ]}
?