【发布时间】:2021-09-18 05:26:51
【问题描述】:
我正在尝试编写一个查询,该查询基于日期范围数组进行过滤,并返回生日字段在其中一个范围内的文档:
const users = await User.aggregate([
{
$match: {
birthday: {
$or: [
{
$lte: "1998-01-01T00:00:00.000Z",
$gte: "1997-01-01T00:00:00.000Z",
},
{
$lte: "2000-01-01T00:00:00.000Z",
$gte: "2001-01-01T00:00:00.000Z",
},
{
$lte: "2002-01-01T00:00:00.000Z",
$gte: "2003-01-01T00:00:00.000Z",
},
],
},
},
},
])
但是,这会返回此错误:
错误 MongoError: 未知操作符: $or
知道怎么做吗?
【问题讨论】:
标签: mongodb mongoose mongodb-query aggregation-framework