I may be over-thinking this after a lot of web searching because a really trivial task is starting to look ugly.
How do I get the sum of a field from a collection? This is boring, accounting kind of stuff. Given:
Ledger = new Mongo.Collection(‘ledger’);
// account: Cash, inventory etc
// amount; positive for debits / negative for credits
// comment: instead of a journal
how do I get, for instance, the sum of records for the Cash account?
I came across meteorhacks:aggregate. The example is a bit spare for my nascent grasp of Mongo, I’m afraid. My attempts to use it are failing.
But it seems like this shouldn’t be this hard to do. What am I missing?