sql >> Base de Datos >  >> NoSQL >> MongoDB

Mongodb (v2.4.0) $match agregado no funciona con el rango de fechas

Tienes que formatear la fecha antes de pasar a $match agregado.

Order.aggregate([
        {
          $match: {
            createdAt: {
              $gte: new Date(req.body.startDate),
              $lt: new Date(req.body.endDate)
            }
          }
        },
        {
          $lookup: {
            from: 'acbinstallerpayments',
            localField: "_id",
            foreignField: 'customerObjectID',
            as: 'installerPaymentDetails'
          }
        }
      ]);