Select object and return as array

I have a query that’s returning the below result. It’s selecting a single object inside an array, however it’s returning it as an object instead of a list with just one object. Is there a way to leave the result inside an array? The specific object is my “property” object, i need it to be a properties array with just one “property” object.

SELECT meta(bn).id as _ID, meta(bn).cas as _CAS, bn.name
FIRST 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

[
    {
        "_CAS": 0000,
        "_ID": "1111",
        "name": "my name",
        "property": {
            "id": "1111",
            "name": "my property name"
        }
    }
]

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