How to add/populate properties from a JSON object when creating a node

Solved it by doing something like`CREATE (a:${label} $props)`, {props: properties})


I'm trying to create an api that'll let users create nodes and relationships with the properties they define and I am using the javascript neo4j driver.

I was wondering if its possible to do something along the lines of:

var label_var = "some_custom_label";

var properties = {
name: "bob",
age: 25
}`CREATE (a:$label ${JSON.stringify(properties)}`, {label: label_var})

and achieve the same result as if I did:

var label_var = "some_custom_label";'CREATE (a:$label {name: "bob", age: 25})', {label: label_var})

essentially I just want to be able to dynamically add properties to a node i'm creating from a JSON object. Is it possible? Thanks!

1 Like