Select object and return as array

Change FIRST To ARRAY

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/collectionops.html

When used FIRST the loop stops when first element satisfied and returns the element.

When used ARRAY the loop continue till end and all qualified elements are returns as ARRAY (i.e. list)

SELECT meta(bn).id as _ID, meta(bn).cas as _CAS, bn.name
    ARRAY t FOR t IN properties WHEN t.id = "1111" END AS property
FROM `bucket-name` as bn
WHERE ANY t IN attributes SATISFIES t.id = "1111" END;
1 Like