我有一个文档,看起来有点像这样:
> db.orders.find()
{
_id: ObjectId(),
_reminders: [{
notified: true,
timestamp: ISODate(),
completed: false
}]
}
{
_id: ObjectId(),
_reminders: []
}我正在尝试查找的是orders集合中的一个文档,其中的“提醒”不包含特定时间范围内的提醒,并且未完成。
db.orders.find({
'_reminders': {
$elemMatch: {
completed: false,
timestamp: { $ne: time }
}
}
});问题是,这将找不到一个没有任何提醒的订单。
如何查询这一点?
https://stackoverflow.com/questions/38333095
复制相似问题