Created
July 25, 2014 10:37
-
-
Save bitomule/96c19313a0db3ee85f08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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