如何在此mongodb聚合函数中执行订单

时间:2019-07-03 11:20:06

标签: mongodb mongodb-query aggregation-framework

我要查询一个状态:“ CLOSED” $或“ PAID_IN_FULL”

阅读文档并尝试了各种方法,但似乎语法不正确

{
    'lineItems.url': /.*mercari.*/i,
    status: 'PAID_IN_FULL',
    createdAt: {
        $gte: ISODate("2019-01-01T00:00:00.000Z"),
        $lt: ISODate("2019-12-20T00:00:00.000Z")
    }
}

{
    'lineItems.url': /.*mercari.*/i,
    status: 'CLOSED',
    createdAt: {
        $gte: ISODate("2019-01-01T00:00:00.000Z"),
        $lt: ISODate("2019-12-20T00:00:00.000Z")
    }
}

1 个答案:

答案 0 :(得分:1)

{
 'lineItems.url': /.*mercari.*/i,
  $or : [
  {  status: 'CLOSED' },
  {  status: 'PAID_IN_FULL' },
 ],  
 createdAt: {
  $gte: ISODate("2019-01-01T00:00:00.000Z"),
  $lt: ISODate("2019-12-20T00:00:00.000Z")
 }
}