我可以在CREATE或SET上参数化标签和属性吗? (REST和事务) [英] Can I parameterize labels and properties on CREATE or SET? (REST and transaction)

查看:128
本文介绍了我可以在CREATE或SET上参数化标签和属性吗? (REST和事务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询

1. CREATE (a:%1$s {props}), (b:%2$s {props2}), (b)-[:%3$s {relProps}]->(a)
2. MATCH (a:%1$s { value:{value} })-[:%2$s]->(b) WHERE (b:%3$s) SET (b {props})

我正在使用underscore.string允许字符串格式,但只希望坚持使用参数.

I'm using underscore.string to allow string format but would love to just stick with parameters.

是否可以参数化标签,例如

Is it possible to parameterize labels such as

{ 
  "query": CREATE (a:{label} {props}),
  "params": {
    "label":"SomeLabel",
    "props":{....}
  }
}

是否还可以在SET上设置属性的参数?

and is it also possible to parameterize properties on a SET?

{
  "query": "MATCH ..... SET (node {props})"
  "params": {
    "props":{
      "prop1:":"Property Name",
      .... 
    }
  }
}

还有没有一种方法可以对"MERGE"进行参数化?它给我参数映射不能用于MERGE模式(请改用文字映射,例如"{id:{param} .id}"))"

Also is there a way to parameterize on a "MERGE"? it gives me 'Parameter maps cannot be used in MERGE patterns (use a literal map instead, eg. "{id: {param}.id}")'

参数化where子句怎么办?

what about parameterizing where clause?

MATCH (:Identity%1$s {nodeId:{nodeId})-[r*2..3]-(node1)-[b:%2$s]->(node2) %4$s return *

我在那里有%4 $ s可以放置我需要的任何子句.如果我想拥有它

I have %4$s there for me to put whatever clauses I need to. If I want to have it as

WHERE node1.nodeId= {someNodeId} SET b= {props}

有可能吗?

此外,在执行事务时,SET node = {props}似乎不起作用.我尝试过

Also when I'm doing a transaction SET node={props} does not seem to work. I tried

statements:[
  {
    "statement":"..... SET node={props}",
    "parameters":{
      "props": {
        "description":"some description"
      }
    }
  }
]

有什么建议吗??谢谢!

Any suggestions?? Thank you!

推荐答案

您无法参数化标签,因为不同标签的查询计划可能看起来有所不同.

You cannot parameterize labels since the query plan might look different for a different label.

可以使用地图对多个属性进行参数化,请注意SET语法略有不同:

Parameterizing multiple properties using a map is possible, note the slight difference in the SET syntax:

{
  "query": "MATCH ..... SET node = {props}"
  "params": {
    "props":{
      "prop1:":"Property Name",
      .... 
    }
  }
}

不是MERGE的100%,但是我想这应该起作用:

Not 100% about MERGE but I guess this should work:

{
  "query": "MERGE (n:Label {identifier: {idValue}) ON CREATE SET n = {props}"
  "params": {
    "identifier": 123,
    "props":{
      "identifier": 123,
      "prop1:":"Property Name",
      .... 
    }
  }
}

这篇关于我可以在CREATE或SET上参数化标签和属性吗? (REST和事务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆