apoc.coll.insertAll

详细信息

语法

apoc.coll.insertAll(coll, index, values)

描述

从指定的索引开始,将所有值插入到 LIST<ANY> 中。

参数

名称

类型

描述

coll

LIST<ANY>

要插入值的列表。

index

INTEGER(整数)

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

值 (values)

LIST<ANY>

要插入的值。

返回

LIST<ANY>

用法示例

以下示例使用 APOC 和 Cypher 在列表的索引 3 处插入值 111213

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

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