I have a collection (UserData) that contains an array with id’s (news) of documents from another collection (News).
Meteor.publish('user-news', function() {
var a = UserData.find({_id: this.userId}, {fields: {_id: 0, news: 1}}).fetch();
return News.find({_id: {$in: a}});
});
Document structure:
{
"_id" : "9PBX38WYi93XQqYGh",
"news" : [
"cfPY52bjfieoLy7eE",
"jggqssAZjT2DBSgbP",
"Tg3KGdd4PADtfqBZE"
]
}
Any idea what I’m doing wrong?