i need exactly this map/reduce function in meteor:
http://cookbook.mongodb.org/patterns/count_tags/
Read all tags from all entries and give back a list of unique tags with the amount in the collection
How would I implement this. I’m using standalone Mongodb.
Collection Layout:
[_id] => 1234
[headline] => My First Post
[body] => Alot of stuff
[isPrivat] =>
[tags] => Array (
[0] => test
[1] => php
[2] => perl
)
I found this question/answer, but I can’t get this to do what I wan’t :
Does Meteor have a distinct query for collections?
What is the most elegant way to do this.
Thank you for your time
At the current moment, the most elegant solution would be aggregation framework:
It will output result like this one:
This is mongodb shell syntax. I not familiar with meteor, so I’ll not try to write some code. Hope this helps!