How do I aggregate the below collection of document type to sum the quantity
of all product_id
sold based on each district_id
and city_id
within a period of time
I tried using the aggregate functions of $match
, $group
but haven't been successful.
{
"_id" : ObjectId("5b115e00a186ae19062b0714"),
"id" : 86164014,
"cost" : 3,
"created_date" : "2017-04-04 21:44:14",
"quantity" : 12,
"bill_id" : 46736603,
"product_id" : 24,
"bill_date" : "2017-04-04",
"district_id" : 75
"city_id": 21
}