List Key Aggregation Count


#1

Hey guys,

I’m not sure how to tackle this exactly, I’d like to write as little code as possible, or process this perhaps at one time.

So let’s say I have two lists

Get Your Animals

  • Big Dog (1)
  • Big Cat (2)

Get Your Friend’s Animals

  • Big Dog (3)
  • Big Cat (1)
  • Small Bird (2)

I’d like to combine the list and increment the counts, so the total would be

  • Big Dogs (4)
  • Big Cats (2)
  • Small Birds (2)

Now for me the tricky part is when to do this, do I it while the database is getting returning the results, while it’s going on make a separate object, or handle this through the dom.

In addition, how do you get an array of the returned value from the data base? Currently I’m doing something like this;

this.view.template.__helpers[' animals']

#2

Hi,
I dont think there is any List data type in js.

So please better describe what is your collection structure and document schema.
And how you are calling these Animals.find for both your and your friends’s cursor.

Regarding counting and filtering I am used to nest helpers cause I am lazy.
Or use map on cursor during my happier days :smiley: