- Agrupando por tipo de produto (ProductName) e para cada tipo, retorna os tipos de uso (UsageType), o custo (BlendedCost) e as operações (Operation) efetuadas.
- O resultado final ($out) fica armazenado em uma nova collection chamada billing_product_usage
db.billing.aggregate( [
{ $match : { PayerAccountId: 264381961167 }},
{ $group : { _id: "$ProductName", usageParams: { $push: { usageType: "$UsageType", cost: "$BlendedCost", operation: "$Operation" } } } },
{ $out: "billing_product_usage" }], { allowDiskUse: true }
)