Reputation: 45
Here's where I am stuck.
set t[x] = value[1]
The property value/key is known only at runtime.
Looking for dynamically setting property values post creation of node something like this:
match (a:User)
with distinct(a.name) as property
Match(b:Product) with property, b.Phone as value
foreach(x in property |
create(t:Test) set t[x] = value[1])
(note the set t[x] = value[1]
)
Or
match (a:User) with distinct(a.name) as property
Match(b:Product) with property, b.Phone as value
foreach(x in property |
call apoc.apoc.create.nodes('Test', [x,value[0]))
(Note the apoc.apoc.create.nodes('Test', [x,value[0])
)
Intension is to User Property's value becomes a Property for Test node.
Upvotes: 1
Views: 791
Reputation: 29172
You can try the apoc.map.setKey
function to set the properties of the map:
WITH {} as props
WITH apoc.map.setKey(props, "name", "Jack") as props
WITH apoc.map.setKey(props, "surname", "Smith") as props
CREATE (N:TEST) SET N = props
RETURN N
Upvotes: 3