How to push values to property array Cypher-Neo4j

前端 未结 3 1549
忘了有多久
忘了有多久 2020-12-24 14:09

I am new to Neo4j,I have two nodes user and files with a relationship :contains, the relationship has a property idwhich

相关标签:
3条回答
  • 2020-12-24 14:36

    In addition to the answer of jjaderberg in case that one of the attribute is null which could result in horrible errors:

    SET n.id = coalesce(n.id, []) + n.additionalId

    The coalesce goes through the comma seperated list (inside the brackets) from left to right and skips the variables that are Null values. So in this case if n.id is initially Null the coalesce would take the second parameter which is the empty array.

    0 讨论(0)
  • 2020-12-24 14:42

    full query for newbies

    MATCH (a:Application {name:'A'})-[r:REQUEST_TO]-(d:Application {name:'B'})
    WHERE ID(r) = 684
    SET r.id = r.id + 'New Id'
    
    0 讨论(0)
  • 2020-12-24 14:45

    Adding values to an array is analogous to incrementing an integer or concatenating a string and is signified the same way, in your case (let c be your [c:contains {id:[12345]}])

    c.id = c.id + 1111             //  [12345,1111]
    c.id = c.id + 14567            //  [12345,1111,14567]
    

    or

    c.id = c.id + [1111,14567]     //  [12345,1111,14567]
    
    0 讨论(0)
提交回复
热议问题