0

How to decompose array value bound?

I tried to use UNWIND clause. But, Unable to access it.

Is there alternative of array binding or method for decomposing array?

santino
  • 9
  • 1

1 Answers1

0

Unfortunately, there is no array bing on AgensGrpah Client API or has very poor performance.

To avoid this problem, You can use binding array object on quires.

Function "json_array_elements" decomposes array to a number of 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
cullen
  • 51
  • 4