I would like to find documents from collections and group it by some fields and sum it together to return it to the helper.
For example : I have
Sales, SaleDetails and
Products Collections and I want to get product name and quantity from saleDetails where Sales is paid. like SQL Code:
SELECT Products.name as name, sum(SaleDetails.quantity) AS quantity FROM (( Sales INNER JOIN SaleDetails ON Sales.Id=SaleDetails.SaleId) INNER JOIN Product ON Product.Id=SaleDetails.ProductId) Where Sale.IsPay=true GROUP BY SaleDetails.ProductId
What should I do with Meteor.js?