【发布时间】:2021-09-18 13:40:37
【问题描述】:
我一直在尝试查询帖子文档。集合的查询如下。
db.getCollection('posts').find({ isActive: true, inappropriateReports: { '$exists': true, '$gt': { '$size': 0 } }})
我能够得到想要的结果,但问题是我一添加日期过滤器 它开始返回空数组作为响应的查询
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 } }})
如何解决这个问题以及对没有“inappropriateReports”字段的集合进行空检查?
提前致谢
【问题讨论】:
标签: node.js database mongodb mongoose filtering