Skip to content

Instantly share code, notes, and snippets.

@solanoize
Created September 30, 2022 12:18
Show Gist options
  • Select an option

  • Save solanoize/2c3da97bc9b50a6ea9f36f502ecf5f04 to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/2c3da97bc9b50a6ea9f36f502ecf5f04 to your computer and use it in GitHub Desktop.
schema.FakturSchema.aggregate(
      [
        {
          $match: {
            statusPengambilan: statusPengambilan,
            // sisa: { $gt: 0 },
            tanggalTerima: {
              $gte: new Date(tanggalAwal),
              $lte: new Date(tanggalAkhir),
            },
          },
        },
        {
          $group: {
            _id: {
              tanggal: { $dayOfMonth: "$tanggalTerima" },
              bulan: { $month: "$tanggalTerima" },
              tahun: { $year: "$tanggalTerima" },
              // nomorHP: "$nomorHP",
            },
            totalHarga: { $sum: "$totalHarga" },
          },
        },
      ],
      (err, result) => {
        if (err) {
          reject(err);
        } else {
          resolve(result);
        }
      }
    );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment