Reputation: 2837
I'm trying iterate on an array and return my collection
I have the following
Meteor.publish('collaborators', function() {
var topics = Topics.findOne({$or:[{
userId: this.userId,
}, {
collaboratorsIds: this.userId,
}, {
inviteeId:this.userId,
}]});
return Collaborators.find({
topicId: topics._id,
});
});
topics
is an array and I would like the Collaborators.find to iterate and return
Upvotes: 0
Views: 259
Reputation: 19544
You can use the $in
operator to include all elements of an array of _id
s:
return Collaborators.find({
topicId: {$in: _.pluck(topics, '_id')},
});
Upvotes: 1