【问题标题】:$and inside $elemMatch not working in Meteor$and inside $elemMatch 在 Meteor 中不起作用
【发布时间】:2014-05-12 07:18:12
【问题描述】:

我有以下问题

{
    lessen: {
        $not: {
            $elemMatch: {
                $and: [
                    {start: {$lt: new Date()}},
                    {eind: {$gt: new Date()}}
                ]
            }
        }
    }
}

在我更新到 Meteor 0.8 之前,它运行良好。现在它抛出Error: Unrecognized operator: $and。有谁知道如何解决这个问题?

【问题讨论】:

  • 我也遇到了这个问题,但是使用了 $or。有什么修复吗?

标签: mongodb meteor minimongo


【解决方案1】:

在这种情况下,您不需要使用 $and 运算符,您可以像这样简单地编写查询:

{
    lessen: {
        $not: {
            $elemMatch: {
                start: {$lt: new Date()},
                eind: {$gt: new Date()}
            }
        }
    }
}

【讨论】:

  • 这不是一个好的答案,问题是问如何使用 $and 运算符,而不是如何重构代码。
猜你喜欢
  • 2014-04-24
  • 2011-12-04
  • 2014-05-30
  • 1970-01-01
  • 1970-01-01
  • 2018-11-13
  • 2013-09-22
  • 2013-08-27
  • 1970-01-01
相关资源
最近更新 更多