如何创建带变量标签的节点?

Vin*_*ent 2 neo4j node.js cypher

看来我无法使用基于userinput的标签创建节点.我想将表单中的user userinput存储在变量中并将其传递给Cypher查询.虽然这似乎适用于属性,但它不适用于标签.我花了半天时间来处理各种可能性:

('CREATE n:{typeParam} {desc:{descParam}, userID: {IDParam}}) RETURN n', {typeParam:type, descParam: desc, userID: id})

('CREATE n (SET n:{typeParam} {desc:{descParam}, userID: {IDParam}}) RETURN n', {typeParam:type, descParam: desc, userID: id})

('CREATE n:($typeParam) {desc:{descParam}, userID: {IDParam}}) RETURN n', {typeParam:type, descParam: desc, userID: id})
Run Code Online (Sandbox Code Playgroud)

label变量的第一个字符始终被视为无效输入.我真的很想知道如何做到这一点.

std*_*b-- 5

您可以使用以下apoc.create.node过程APOC library:

CALL apoc.create.node(
  // array of labels
  [{typeParam}],

  // property object
  {
    desc: {descParam}, 
    usedID: {userID}
  } 
)
Run Code Online (Sandbox Code Playgroud)