I have been trying to query the Document of posts. The query for the collection is as follows.
db.getCollection('posts').find({ isActive: true, inappropriateReports: { '$exists': true, '$gt': { '$size': 0 } }})
I am able to get the desired results but the issue is as soon as I add the date filter for the query it starts returning the empty array as a response
db.getCollection('tribe-posts').find({ isActive: true,
createdAt: {
'$gte': '2021-06-01T00:00:00.000Z',
'$lte': '2021-07-07T00:00:00.000Z'
},
inappropriateReports: { '$exists': true, '$gt': { '$size': 0 } }})
How do I solve this issue as well as have a null check for the collections that doesn't have "inappropriateReports" field?
Thanks in advance