Parameters, value
Collection operation can aggregate a column of nodes, edges, paths, property values or schemas into an array in the original order, as long as it is a column of elements, it can be converted into an array by collect()
.
Syntax:
- format: collect(
<column>
) - parameters: (see list below)
- value: ARRAY
Name | Category | Specification | Description |
---|---|---|---|
<column> |
NODE,EDGE,PATH,ATTR,ARRAY,TABLE | / | The column to be aggregated |
<column>
's value for each category of <column>
:
Category | value |
---|---|
NODE | NODE's UUID in the column |
EDGE | EDGE's UUID in the column |
PATH | ROW INDEX(starting from 0)in the column |
ATTR | ATTR's value in the column |
ARRAY | ARRAY'S value in the column |
TABLE | Value of the array transformed from the table in the column |
ATTR
Example: find 10 nodes and collect their schema
find().nodes([1,2,3,4,5,6,7,8,9,10]) as n
return collect(n.@)
NODE
Example: find 10 @product
nodes, collect their UUID
find().nodes({@product}) as n
limit 10
return collect(n)
EDGE
Example: find 10 @transfer
edges, collect their UUID
find().edges({@transfer}) as e
limit 10
return collect(e)
PATH
Example: find 10 shortest paths from Card CA001 within 2 steps, list the paths by the destination card's balances by descending order, and collect the column number of the paths.
n({_id == "CA001"}).e({@transfer})[2].n(as n).limit(10) as p
order by n.balance desc
return collect(p)
Analysis: the column number of the paths in the stream starts from 0,
ARRAY
Example: find paths from Card CA001 within 3 steps, count the number of the nodes of each path, then collect these nodes
n({_id == "CA001"}).e()[3].n() as p
with pnodes(p) as a
return collect(a)