[英]Can I parameterize labels and properties on CREATE or SET? (REST and transaction)
I have a query 我有一个问题
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})
I'm using underscore.string to allow string format but would love to just stick with parameters. 我使用underscore.string来允许字符串格式,但是只想坚持使用参数。
Is it possible to parameterize labels such as 是否可以参数化标签,如
{
"query": CREATE (a:{label} {props}),
"params": {
"label":"SomeLabel",
"props":{....}
}
}
and is it also possible to parameterize properties on a SET? 是否也可以在SET上参数化属性?
{
"query": "MATCH ..... SET (node {props})"
"params": {
"props":{
"prop1:":"Property Name",
....
}
}
}
Also is there a way to parameterize on a "MERGE"? 还有一种方法可以参数化“MERGE”吗? it gives me 'Parameter maps cannot be used in MERGE patterns (use a literal map instead, eg. "{id: {param}.id}")' 它给了我'参数贴图不能用于MERGE模式(改为使用文字贴图,例如。“{id:{param} .id}”)'
EDIT: what about parameterizing where clause? 编辑:参数化where子句怎么样?
MATCH (:Identity%1$s {nodeId:{nodeId})-[r*2..3]-(node1)-[b:%2$s]->(node2) %4$s return *
I have %4$s there for me to put whatever clauses I need to. 我有%4 $ s在那里让我放置我需要的任何条款。 If I want to have it as 如果我想拥有它
WHERE node1.nodeId= {someNodeId} SET b= {props}
is that possible?? 那可能吗??
Also when I'm doing a transaction SET node={props} does not seem to work. 此外,当我正在做一个事务SET节点= {props}似乎不起作用。 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. 您无法参数化标签,因为查询计划对于其他标签可能看起来不同。
Parameterizing multiple properties using a map is possible, note the slight difference in the SET
syntax: 可以使用地图参数化多个属性,请注意SET
语法中的细微差别:
{
"query": "MATCH ..... SET node = {props}"
"params": {
"props":{
"prop1:":"Property Name",
....
}
}
}
Not 100% about MERGE
but I guess this should work: 不是100%关于MERGE
但我想这应该工作:
{
"query": "MERGE (n:Label {identifier: {idValue}) ON CREATE SET n = {props}"
"params": {
"identifier": 123,
"props":{
"identifier": 123,
"prop1:":"Property Name",
....
}
}
}
I found out! 我发现!
CREATE ... SET node = {props}
does the trick to set multiple properties with parameters 使用参数设置多个属性的技巧
doc: http://docs.neo4j.org/chunked/snapshot/cypher-parameters.html doc: http : //docs.neo4j.org/chunked/snapshot/cypher-parameters.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.