I have a server side mongo assembly called Profiles.
I need to publish and subscribe to the entire collection of profiles if the user is: adminId.
Thus, the administrator can edit, update, etc. each item in the profile collection.
But I want users to be able to see their record in the report.
So, I tried this ...
CLIENT PARTY
MyProfile = new Meteor.Collection("myprofile");
Meteor.subscribe('profiles');
Meteor.subscribe('myprofile');
GENERAL - CUSTOMER AND SERVER
Profiles = new Meteor.Collection("profiles");
SERVER SIDE - Publishing and subscribing to profiles work fine.
Meteor.publish("profiles", function() {
var user_groups = Groups.find({users: this.userId()});
var user_groups_selector = [];
user_groups.forEach(function (group) {
user_groups_selector.push(group._id);
});
return Profiles.find( {
acl_group_fetch: {
$in: user_groups_selector
}
});
});
This is where the problem begins. Profiles.find returns the elements of the collection, because I can output them to the console server. But for some reason, publication and subscription do not work. The client does not receive anything.
Meteor.publish("myprofile", function() {
return Profiles.find({user: this.userId()});
});
, . , A , , , , B (C, D E) .