Hello, I'm trying to do the below and was wondering if it was possible? I'd like to use the property value of a node as a key on another node to get it' value. I've seen how one sets params and then can use the dollar sign within square braces to get a property - but not sure how that would be done here. Thanks in advance
match (p:Product)-[:HAS_FIELD]->(field:FieldConfig)
with *, field.name as fieldName
where field.type = 'important'
return distinct p.name, p.productId,field.name,field.type, p[fieldName] limit 25
@joe5
Sorry if I not understand, but the provided query seems to work.
That is, if I have a dataset like: create (p:Product {test: 'another'})-[:HAS_FIELD]->(field:FieldConfig {name: 'test', type: 'important'}),
the p[fieldName] return 'another' (in my example case).
Maybe you want to handle a SET clause?
In this case you could use the APOC procedures, in particular the apoc.create.setProperty ,
for example you could set a property with key the value of FieldConfig.name and value 'whatever':
MATCH (p:Product)-[:HAS_FIELD]->(field:FieldConfig)
WITH *, field.name as fieldName
CALL apoc.create.setProperty(p, fieldName, 'whatever') yield node
RETURN *