Select object nested in array

I’m trying to select the object that contains UniId and iProgramId where UniId = 1234 and iProgramId = “xyz” inside the array element myArray. How do I achieve it? I’m new to Couchbase.

{
“myArray”: [
{
“UniId”: 1234,
“iProgramId”: “xyz”
}
{
“UniId”: 5678,
“iProgramId”: “xyz”
}
],
“userId”: 1000001
}

If you need whole document

SELECT d.*
FROM mybucket AS d
WHERE ANY v IN d.myArray SATISFIES v.UniId = 1234 AND v.iPgrogramId = "xyz" END

If you need only portion of the object matched

SELECT u.*
FROM mybucket AS d
UNNEST d.myArray AS u
WHERE u.UniId = 1234 AND u.iPgrogramId = "xyz"
2 Likes

This works. Thank you! I really appreciate it