Neo4j Add/update properties if node exists

前端 未结 3 1626
陌清茗
陌清茗 2020-12-29 08:11

I want to be able to update/enlarge my Neo4j database by uploading a newer version of that database OR part of that database.

Of what I\'ve found I can

3条回答
  •  别那么骄傲
    2020-12-29 08:27

    You could merge the node on John (or the primary identifying attribute). And then set the properties after the successful merge.

    You could set them all at once with a map for all attributes

    MERGE (n:Node {name: 'John'})
    SET n = {name: 'John', age: 34, coat: 'Yellow', hair: 'Brown'}
    RETURN n
    

    If you just wanted to replace the attributes age and coat, you could do this instead.

    MERGE (n:Node {name: 'John'})
    SET n.age = 34, n.coat = 'Yellow'
    RETURN n 
    

    Or you could add it as a map too

    MERGE (n:Node {name: 'John'})
    SET n += {age: 34, coat: 'Yellow'}
    RETURN n 
    

提交回复
热议问题