It’s a very simple query to pick up an array
Select Array from `bucket-name` WHERE meta().id = "id";
however I’m getting back an array of arrays:
[
{
"Array": [
"arrayId1",
"arrayId2"
]
}
]
I’m trying to use the result of my query in an another query, so it’s a subquery, if there’s an easier way to do this, maybe LIKE or contains? I’m open to that as well
N1QL is very composable.
You can use this query as a subquery anywhere a query expression is used.
Once you name the result of these expression, you an use it to reference the array.
Some examples:
SELECT *
FROM (Select Array
from test
WHERE meta().id = “id”) AS t1
SELECT *
FROM 1 AS t1
WHERE EXISTS (Select `Array` from `test` WHERE meta().id = "id")
SELECT t1a
FROM (Select `Array` from `test` WHERE meta().id = "id") as t1
UNNEST t1.`Array` as t1a
Select Array
, array_contains(Array
, “arrayId1”) from test
WHERE meta().id = “id”;