In eshop we have Product view and in mongo product document we have property - array of accessories _id’s.
I need to call subscribe with argument ( our main product _id) and get back max 3 documents from each category Cause we are not going to show more in this view.
For now I am thinking about this approach:
findOne that main product _id, get accessoriesList from it
Products.find where _id is in accessoriesList
Than want to transform results by aggregate
And than publish them using publish low level API to custom clientside collection.
Am I thinking in the right direction? @awatson1978
As usual, standard pipeline aggregation could not solve it easily as it does not support $limit per key
So I added mapReduce to meteorhacks:meteor-aggregate package and submitted PR for review https://github.com/ShockiTV/meteor-aggregate
And now back to working directly on our eshop project.