text: import { Meteor } from 'meteor/meteor';
  import { Profiles } from '../../api/profiles/Profiles';
  import { Filters } from '../../api/filters/Filters';
  
  // User-level publication.
  
  // If logged in, then publish all profile documents. Otherwise publish nothing.
  Meteor.publish(Profiles.userPublicationName, function () {
    if (this.userId) {
      return Profiles.collection.find();
    }
    return this.ready();
  });
  
  // If logged in, then publish the filter document of the logged in user. Otherwise publish nothing.
  Meteor.publish(Filters.userPublicationName, function () {
    if (this.userId) {
      const username = Meteor.users.findOne(this.userId).username;
      return Profiles.collection.find({ owner: username });
    }
    return this.ready();
  });
  
  // alanning:roles publication
  // Recommended code to publish roles for each user.
  Meteor.publish(null, function () {
    if (this.userId) {
      return Meteor.roleAssignment.find({ 'user._id': this.userId });
    }
    return this.ready();
  });
  