I have a MongoDB collection which looks like this:
{
_id: "some-long-id-1"
name: "John Doe",
activities: [
{ name: "Lunch", status: "SCHEDULED" },
{ name: "Playing Football", status: "COMPLETED" },
{ name: "Workout", status: "COMPLETED" },
]
},
{
_id: "some-long-id-2"
name: "Jane Doe",
activities: [
{ name: "Lunch", status: "COMPLETED" },
{ name: "Playing Football", status: "SCHEDULED" },
{ name: "Workout", status: "COMPLETED" },
]
}
I want to query all the objects which has activities which contains at least one consecutive COMPLETED status. For example, the query should return some-long-id-1 object as it has a consecutive COMPLETED status in the activities array. It shouldn't return some-long-id-2 as even though there are two arrays with COMPLETED status but they are not consecutive.