Need help with query to filter the records in mongoDB. I am using compass to run the que We have thousands of records/documents where each record/document contains the following array. For few documents, the events in lifeCycleinfo
are out of order i.e. payment.completed
event comes before 1payment.completed1 event.
I need to filter those records where payment.completed
event comes before payment.created
event.
Sample Object:
{
"lifeCycleInfo": [
{
"eventId": "9b8b6adfae",
"eventSubType": "SendTransfer_Receipt",
"eventType": "SendTransfer",
"odsTimestamp": {
"$date": "2023-02-06T14:33:42.308Z"
},
"payload": "{}",
"timestamp": {
"$date": "2023-02-06T14:33:42.271Z"
}
},
{
"eventId": "06e8d144-531b02",
"eventSubType": "payment.created",
"eventType": "Notification",
"odsTimestamp": {
"$date": "2023-02-06T14:33:45.488Z"
},
"payload": "{}",
"timestamp": {
"$date": "2023-02-06T14:33:45.479Z"
}
},
{
"eventId": "9da54454d6",
"eventSubType": "payment.completed",
"eventType": "Notification",
"odsTimestamp": {
"$date": "2023-02-06T14:33:46.698Z"
},
"payload": "{}",
"timestamp": {
"$date": "2023-02-06T14:33:46.689Z"
}
}
]
}
I tried to find it based on array index but not working.
{"lifeCycleInfo[1].eventtype":"payment.completed"}