text: import { Meteor } from 'meteor/meteor';
  import { Roles } from 'meteor/alanning:roles';
  import { Stuffs } from '../../api/stuff/Stuff';
  import { Contacts } from '../../api/contact/Contacts';
  
  /** This subscription publishes only the documents associated with the logged in user */
  Meteor.publish('Stuff', function publish() {
    if (this.userId) {
      const username = Meteor.users.findOne(this.userId).username;
      return Stuffs.find({ owner: username });
    }
    return this.ready();
  });
  
  /** This subscription publishes all documents regardless of user, but only if the logged in user is the Admin. */
  Meteor.publish('StuffAdmin', function publish() {
    if (this.userId && Roles.userIsInRole(this.userId, 'admin')) {
      return Stuffs.find();
    }
    return this.ready();
  });
  
  /** This subscription publishes only the documents associated with the logged in user */
  Meteor.publish('Contacts', function publish() {
    if (this.userId) {
      const username = Meteor.users.findOne(this.userId).username;
      return Contacts.find({ owner: username });
    }
    return this.ready();
  });
  
  /** This subscription publishes all documents regardless of user, but only if the logged in user is the Admin. */
  Meteor.publish('ContactsAdmin', function publish() {
    if (this.userId && Roles.userIsInRole(this.userId, 'admin')) {
      return Contacts.find();
    }
    return this.ready();
  });
  