Hi everyone, I'm having problem with mongodb aggreagation. I don't know why but the command always return empty result even with the simplest command ($match only 1 property). Here is the example code :
$data = Orders::aggregate([
[
'$match' => [
'userId' => $this->user->getId(),
'domain' => $domain,
'created_at' => [
'$gte' => new UTCDateTime(1000 * mktime(0, 0, 0, date("n", $from), date('j', $from), date('Y', $from))),
'$lte' => new UTCDateTime(1000 * mktime(0, 0, 0, date("n", $to), date('j', $to), date('Y', $to)))
]
],
],
[
'$unwind' => '$fulfillments_data'
],
[
'$group' => [
'_id' => [
'month' => [
'$month' => '$created_at'
],
'day' => [
'$dayOfMonth' => '$created_at'
],
'year' => [
'$year' => '$created_at'
]
],
'revenue' => [
'$sum' => '$total_price'
],
'shopify_fee' => [
'$sum' => '$shopify_transaction_fee'
],
'paygate_fee' => [
'$sum' => '$paygate_transaction_fee'
],
'fulfilment_fee' => [
'$sum' => '$fulfillments_data.orderPrice'
],
]
]
]);
Any Suggestion ?
Thanks