In my application I have a collection that is a list of videos, which bring only the videos of the authenticated user and would like to publish the same collection to bring the latest 5 videos but from all users. I'm doing the following but without success:
//CLIENT
PlayLists = new Meteor.Collection('playlists');
LatestLists = new Meteor.Collection("latestlists");
Meteor.autosubscribe(function () {
Meteor.subscribe('playlists', Session.get('listkey'));
Meteor.subscribe('latestlists');
});
Template.latestlist.latest = function(argument) {
return LatestLists.find({});
};
Template.list.playlist = function(argument) {
return PlayLists.find({});
};
//SERVER
PlayLists = new Meteor.Collection('playlists');
LatestLists = new Meteor.Collection("latestlists");
Meteor.publish('playlists', function (playlist) {
return PlayLists.find({}, {user:this.userId()});
});
Meteor.publish('latestlists', function(){
return PlayLists.find({}, {sort:{when:-1}, limit:5});
});
When i run the app, my latestlist collection allways is empty. what is the best way to achive this?
Thanks in advance