Reputation: 1613
If I have Couchbase documents that look like this:
{
"history": {
"id": "123",
"date": "today",
"status_history": [
{
"code": "0",
"message": "success",
"status": "complete"
}
],
"other": "other"
}
}
If I want to get all the documents from today I can do something like select * from 'my_bucket' where history.date = "today"
But how can I get something like status from status_history that is in an array structure?
select * from 'my_bucket' where history.status_history. status?? = "complete"
Upvotes: 1
Views: 601
Reputation: 566
In addition to the []
syntax for specific array elements, you can also use ANY
and ALL
if you want to make sure that any element (or all of them) satisfies some condition. For example:
select * from my_bucket
where any s in status_history satisfies s.status = 'complete' end;
Upvotes: 2
Reputation: 26169
You can address array elements using []
syntax.
For instance:
SELECT h.*
FROM my_bucket h
WHERE h.status_history[0].status = 'complete'
Upvotes: 1