Users insert links into Mongo Collection and I want to retrieve most popular ones based on how many times is particular link in the collection. For a static data like how many links are coming from Youtube you can do the following:
Meteor.users.find({ "site": "youtube" }).count()
but how to go about dynamic data, as an example such a links:
Meteor.users.find({ "url": "youtube.com/watch?v=u1z4vkPWkLQ" }).count()
EDIT:
How to display on the client? When I do the following, there is an Error in console saying Videos.aggregate in not a function.
Template.frontPage.helpers({
mostDownloadedVideos: function() {
return Videos.aggregate(
[
{ $unwind : "$filename"},
{ $group : { _id : "$filename", number : { $sum : 1} } },
{ $sort : {number : -1} },
{ $limit : 3 }
]
);
}
});