0

如何分解数组值绑定?

我尝试使用 UNWIND 子句。但是,无法访问它。

是否有替代数组绑定或分解数组的方法?

4

1 回答 1

0

不幸的是,AgensGrpah 客户端 API 上没有数组 bing,或者性能很差。

为避免此问题,您可以在 quires 上使用绑定数组对象。

函数“json_array_elements”将数组分解为多个元素。

agens=# prepare arr_bind ( json ) as
agens-#     optional match (n) with $1 as arr limit 1
agens-#     with json_array_elements( arr ) as elem
agens-#     create ({'id':elem.id,'value':elem.value});
PREPARE
agens=# execute arr_bind ( '[ {"id":1,"value":"a"}, {"id":2,"value":"b"}, {"id":3,"value":"c"} ]' );
GRAPH WRITE (INSERT VERTEX 3, INSERT EDGE 0)
agens=# match (n) return n;
                   n                   
---------------------------------------
 ag_vertex[1.1]{"id": 1, "value": "a"}
 ag_vertex[1.2]{"id": 2, "value": "b"}
 ag_vertex[1.3]{"id": 3, "value": "c"}
(3 rows)

agens=# deallocate arr_bind;
DEALLOCATE
于 2019-03-29T05:52:21.147 回答