Orientdb: how to return a Item in a array

299 views Asked by At

I read all the orientdb latest document, unfortunately, I don't find any function can return a item or its position. The statement is as follow:

Select orderlines.Pcs 
from Orders 
where '3b406df3-6ee9-4e24-b244-a60da2217f51' IN  orderlines.Product_no

Orderlines is a array containing two Product_no, what I want is to get the Pcs '21' of first item in orderlines instead of the array [21,56].

I know ArrangoDB has filter function can operate the array directly.

Any help would be much appreciate, thanks.

The data sample of Orderlines are as follows:

[ {"Product_no":"3b406df3-6ee9-4e24-b244-a60da2217f51","Pcs":21}
,{"Product_no":"55adc727-85f3-484b-a436-c31930739388","Pcs":56} ]
1

There are 1 answers

0
Jason Zhang On

Now I got a solution using unwinding, I am not sure is this only way to do this:

select orderlines.Pcs from

(select orderlines from Orders unwind orderlines)

Where orderlines.Product_no='3b406df3-6ee9-4e24-b244-a60da2217f51'