Reputation: 48
Is there a way to modify a returned property without affecting the actual property in Neo4j? I have tried to use SET Clause, but it modifies the actual property in the database.
Take as an example this query for https://console.neo4j.org/:
match (n:Crew)
//change n.name = "my_value"
return n
How can I get the output below without changing the actual name property?
(0:Crew {name:"my_value"})
(1:Crew {name:"my_value"})
(2:Crew {name:"my_value"})
(3:Crew:Matrix {name:"my_value"})
Upvotes: 0
Views: 314
Reputation: 67044
You could use a map projection to return a map of all the properties of each node, with some of the properties being overridden, like this:
MATCH (n:Crew)
RETURN n {.*, name: 'my_value'}
However, this will not generate a visualization, since the returned n
would not be a node (it would just be a map).
If you want to visualize the result, you should look into using virtual nodes and relationships. You should also use the Neo4j Browser instead of https://console.neo4j.org/, as the latter may not properly visualize virtual nodes and relationships.
Upvotes: 2
Reputation: 48
I don' know if this is the right way to achieve this, but here is how I did it:
match (n:Crew)
return {name: "my_value"} as n
Other properties of n
can be placed inside of this custom object.
Upvotes: 0