I want to pass property name in as a parameter in neo4j in merge statement

:param prameter=> 'name';

with $prameter as par
match (u:user) where con[par] is not null with u,par
merge (d:details {par:u[par]}) return d

-- the above one is neo4j considering "merge (d:details {par" <- par as a property name but I want to pass name as property could any one please suggest on this.

match (u:user) where con[$prameter] is not null with u,$prameter
merge (d:details {$prameter:u[$prameter]}) return d

when I run aboe it is throwing error

Invalid input '{': expected a parameter (line 3, column 16 (offset: 105))

You can not use a variable as a key in a map, in your first query m, ‘par’ will be be the key; it will not use the value of par as the key. In your second query, you are getting an error because you can not use an expression as a key, $parameter can not be the key. To do what you want, you can create a map with dynamic keys using an apoc function and set the nide variable to the map or use apoc.merge.node and pass the property map.

https://neo4j.com/labs/apoc/4.1/overview/apoc.merge/apoc.merge.node/

https://neo4j.com/labs/apoc/4.1/overview/apoc.map/apoc.map.fromLists/