在我的应用程序中,我有一个集合,它是一个视频列表,它只带来经过身份验证的用户的视频,并希望发布相同的集合以带来来自所有用户的最新 5 个视频。我正在做以下但没有成功:
//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});
});
当我运行该应用程序时,我的最新列表集合始终为空。实现这一目标的最佳方法是什么?
提前致谢