For sure I can provide more details. Actually here is my function
static async getHistoryData({ type, contract, areas, filters, timestamp, duration, isAwol, projection, lean = false, isUnavailable = false }) {
return model.find(processFilter({ type, contract, areas, filters, timestamp, duration, isAwol, isUnavailable }), projection).lean(lean);
}
processFilter returns the following filter:
{
"$and": [
{
"meta_data.data.area.id": {
"$in": [
"63f882df2d65a5368041937b",
"6511a85fdbadd710cace1a28",
"651d772aaa6d4dc89c14bfe2",
"651d773aaa6d4dc89c14bff6",
"651d774baa6d4dc89c14c00a",
"651d7e4eaa6d4dc89c14c3ea",
"651d7e5eaa6d4dc89c14c3fe",
"651d7e75aa6d4dc89c14c412",
"651d8455aa6d4dc89c14c613",
"651d846baa6d4dc89c14c627"
]
}
},
{
"available_from": {
"$lte": ISODate("2023-12-06T00:37:07.000Z")
}
},
{
"available_to": {
"$gte": ISODate("2023-12-06T00:37:07.000Z")
}
},
{
"meta_data.data.area.type": {
"$in": [
"normal",
"prm",
"chargin_station"
]
}
},
{
"result": {
"$ne": "unavailable"
}
}
]
}
it should return:
[
{
"_id" : ObjectId("656fc4f3be10b23d785f17f7"),
"available_from" : ISODate("2023-12-06T00:36:50.000Z"),
"available_to" : ISODate("2023-12-06T00:39:10.999Z"),
"result" : "spot",
"meta_data" : {
"data" : {
"area" : {
"type" : "normal",
"id" : "63f882df2d65a5368041937b"
}
}
}
},
...other results
]
but sometimes this kind of query returns 0 result and I can’t explain why.