|| apoc.coll.insert - APOC 核心文档 - Neo4j 文档

apoc.coll.insert

详情

语法

apoc.coll.insert(coll, index, value)

描述

将值插入 LIST<ANY> 中指定的索引位置。

参数

名称

类型

描述

coll

LIST<ANY>

要插入值的列表。

index

INTEGER

要插入给定值在列表中的位置。

value

ANY

要插入的值。

返回

LIST<ANY>

使用示例

以下示例使用 APOC 和 Cypher 将值 11 插入列表的索引 3 处。

apoc.coll.insert
WITH [1,3,5,7,9] AS originalList, 3 AS index, 11 AS itemToInsert
RETURN apoc.coll.insert(originalList, index, itemToInsert) AS output;
使用 Cypher 的列表连接
WITH [1,3,5,7,9] AS originalList, 3 AS index, 11 AS itemToInsert
RETURN originalList[0..index] + itemToInsert + originalList[index..] AS output
结果
输出

[1, 3, 5, 11, 7, 9]

© . This site is unofficial and not affiliated with Neo4j, Inc.