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
}
vsr1
October 22, 2022, 7:05pm
2
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"
With the SELECT statement, you can query and manipulate JSON data. You can select, join, project, nest, unnest, group, and sort in a single SELECT statement.
2 Likes
This works. Thank you! I really appreciate it