|| apoc.map.updateTree - APOC 核心文档 - Neo4j 文档

apoc.map.updateTree

详情

语法

apoc.map.updateTree(tree, key, data)

描述

在嵌套树的每个层级上添加 MAP 数据,其中键值对匹配。

参数

名称

类型

描述

tree

MAP

要更新的映射。

key

STRING

要匹配的键的名称。

data

LIST<LIST<ANY>>

一个对列表,其中第一项是与给定键匹配的值,第二项是要添加到树中的映射。

返回

MAP

使用示例

以下示例更新了一个嵌套映射,根据 id 键的值添加额外的键/值

RETURN apoc.map.updateTree({
  id:1,
  c:{
    id:2
  },
  d:[
    {id:3},
    {id:4}
  ],
  e: {notId: 5}
},'id',[
  [1,{description: "Added where id=1"}],
  [2,{description: "Added where id=2"}],
  [3,{description: "Added where id=3"}],
  [4,{description: "Added where id=4"}]
]) AS value;
结果
输出
{
  "id": 1,
  "description": "Added where id=1",
  "c": {
    "id": 2,
    "description": "Added where id=2"
  },
  "d": [
    {
      "id": 3,
      "description": "Added where id=3"
    },
    {
      "id": 4,
      "description": "Added where id=4"
    }
  ],
  "e": {
    "notId": 5
  }
}
© . This site is unofficial and not affiliated with Neo4j, Inc.