publications.js
636 Bytes
import { Meteor } from 'meteor/meteor';
import { check, Match } from 'meteor/check'
import { Users } from '/imports/collections/users/index';
import { Orgs } from '/imports/collections/orgs/index';
Meteor.publish('users.current', function() {
return Users.find({
_id: this.userId,
});
});
Meteor.publish('users.forMyOrg', function() {
const user = Users.findOne({_id: this.userId});
if(!user) return [];
const org = Orgs.findOne({_id: user.orgId});
if(!org) return [];
return Users.find({
orgId: user.orgId
});
});