apoc.coll.insert
语法 |
|
||
描述 |
将值插入 |
||
参数 |
名称 |
类型 |
描述 |
|
|
要插入值的列表。 |
|
|
|
要插入给定值在列表中的位置。 |
|
|
|
要插入的值。 |
|
返回 |
|
||
使用示例
以下示例使用 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] |