I have data something like this
{
"_id": ObjectId("52ed12c144aecc4bf004d0b6"),
"active": true,
"name": "woslo",
"specialDays": [
{
"_id": ObjectId("5f0576196198a715b0a72c14")
"status": true
"date": 2020-07-08T04:00:00.000+00:00
},
{
"_id": ObjectId("5f05a3726198a715b0a72c94")
"status": false
"date": 2020-07-09T04:00:00.000+00:00
}
]
}
I want to fetch records using this query
db.serviceProviders.aggregate([ { $match: { specialDays: { $elemMatch: { $or: [ { $and: [ { date: model.date // 2020-07-09T06:00:00.000Z }, { status: true } ] }, { date: { $ne: model.date //2020-07-09T06:00:00.000Z } } ] } } } } ]);
Scenario is : if date is present in specialDays array and the status should be true , or date should not be in specialDays Object's array then fetch this record. But every time it's fetching the same record that is above even status is false or date is present in array. Would you please help me how to figure it out, I tried a lot of queries in Mongo compass aggregation with ISODate('2020-07-08') but still not working. Thank you Happy Coding.