Reputation: 101
I have a really simple to-do app where users enter a to-do and a tag then submit. When I click a tag on the left side, it displays the to-do that is associated with it. I would like to filter the list on the left side by unique tags. I can't seem to find it anywhere. Any help?
https://i.sstatic.net/SuJmk.png
https://i.sstatic.net/6ic6Q.png
Upvotes: 0
Views: 373
Reputation: 101
This is what works:
Template.all.helpers({
linkList: function() {
var everything = *yourCollection*.find().fetch();
var *yourUniqueFieldItems* = _.pluck(everything,"*YourField*");
return _.uniq(*yourUniqueFieldItems*);
},
The top voted answer here: Meteor: how to search for only distinct field values aka a collection.distinct("fieldname") similar to Mongo's doesn't work, but the author of that post found a solution himself. Unfortunately, it's buried in the comments and it's not the actual answer.
Upvotes: 1