user697911
user697911

Reputation: 10551

How to return a node property expressed by a variable?

MATCH (p:Product {id:'123'}) return p.$color

Where '$color' is a parameter passed from a function which generates the cypher query.

Upvotes: 0

Views: 35

Answers (1)

cybersam
cybersam

Reputation: 67019

You can get the value of a property named "foo" from a p node by using the p["foo"] syntax.

So, if you have a $color parameter that has the name of a Product property, this would work:

MATCH (p:Product {id:'123'})
RETURN p[$color];

Upvotes: 1

Related Questions