Skip to content

Instantly share code, notes, and snippets.

@bitomule
Created July 25, 2014 10:37
Show Gist options
  • Save bitomule/96c19313a0db3ee85f08 to your computer and use it in GitHub Desktop.
Save bitomule/96c19313a0db3ee85f08 to your computer and use it in GitHub Desktop.
Meteor.publish('userDomain', function(domainName) {
var domain,users;
domain = Domains.find({name:domainName});
if(domain.count() <= 0)
{
this.ready();
return null;
}
var domainId = domain.fetch()[0]._id;
if(!domainId)
{
this.ready();
return null
}
if(!this.userId)
{
this.ready();
return null
}
var query = {};
query['roles.' + domainId] = {$exists:true};
users = Meteor.users.find(query,{
fields:{username:1,roles:1}
});
return [domain,users];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment