Reputation: 8212
Using nodejs "neo4j-driver": "^1.1.1"
Is there a way to temporarily format a node's data before returning it? Primarily, I want to remove the id before returning it to the client. I'm not sure if the id being returned is part of neo4j itself or the neo4j-driver, in any case, the question could hold true for any property.
Generally, I specifically layout what I want to return:
RETURN {
uuid: n.uuid,
name: n.name,
etc...
}
But I ran into a situation where I need to return and unknown node, but want to ensure it does not have a few specific properties. I want to temporarily remove those properties before returning — I don't want to make the change permanent in the databse. I realize I can do this in code on the server, but was curious about doing it with Neo4j.
For example:
MATCH (n)
WITH n AS node // I thought about using properties(n) AS node, but then I can't find in the documentation how to modify MAP properties without using a third party plugin. I'm sure there is something in APOC, I haven't looked yet.
REMOVE node.id, node.name // I want this to only temporarily remove the property for purposes of returning, not alter it in the database.
RETURN node
Is there something like this available with neo4j or should I just stick with manually doing it in code?
Upvotes: 1
Views: 92
Reputation: 30407
You'll probably need APOC Procedures for this, as its map helper functions should be helpful.
match (n)
return apoc.map.removeKeys(n, ['id', 'name']) as n
Upvotes: 1