publish() {
    if (Meteor.isServer) {
      // get the HoursCollection instance.
      const instance = this;
      /** This subscription publishes all documents regardless of user, but only if the logged in user is a volunteer. */
      Meteor.publish(HoursPublications.hoursVol, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.VOLUNTEER)) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ volunteer: username });
        }
        return this.ready();
      });

      /** This subscription publishes all documents regardless of user, but only if the logged in user is the organization. */
      // CHANGE ROLE.USER TO ORGANIZATION ONCE ROLE IS MADE
      Meteor.publish(HoursPublications.hoursOrg, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.USER)) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ organization: username });
        }
        return this.ready();
      });

      /** This subscription publishes all documents regardless of user, but only if the logged in user is the Admin. */
      Meteor.publish(HoursPublications.hoursAdmin, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.ADMIN)) {
          return instance._collection.find();
        }
        return this.ready();
      });
    }
  }
/**
   * Default publication method for entities.
   * It publishes the entire collection for admin and just the Event associated to an owner.
   */
Default publication method for entities.
It publishes the entire collection for admin and just the Event associated to an owner.
Default publication method for entities . It publishes the entire collection for admin and just the Event associated to an owner .
publish() {
    if (Meteor.isServer) {
      const instance = this;
      Meteor.publish(HoursPublications.hoursVol, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.VOLUNTEER)) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ volunteer: username });
        }
        return this.ready();
      });
      Meteor.publish(HoursPublications.hoursOrg, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.USER)) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ organization: username });
        }
        return this.ready();
      });
      Meteor.publish(HoursPublications.hoursAdmin, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.ADMIN)) {
          return instance._collection.find();
        }
        return this.ready();
      });
    }
  }
publish ( ) { if ( Meteor . isServer ) { const instance = this ; Meteor . publish ( HoursPublications . hoursVol , function publish ( ) { if ( this . userId && Roles . userIsInRole ( this . userId , ROLE . VOLUNTEER ) ) { const username = Meteor . users . findOne ( this . userId ) . username ; return instance . _collection . find ( { volunteer : username } ) ; } return this . ready ( ) ; } ) ; Meteor . publish ( HoursPublications . hoursOrg , function publish ( ) { if ( this . userId && Roles . userIsInRole ( this . userId , ROLE . USER ) ) { const username = Meteor . users . findOne ( this . userId ) . username ; return instance . _collection . find ( { organization : username } ) ; } return this . ready ( ) ; } ) ; Meteor . publish ( HoursPublications . hoursAdmin , function publish ( ) { if ( this . userId && Roles . userIsInRole ( this . userId , ROLE . ADMIN ) ) { return instance . _collection . find ( ) ; } return this . ready ( ) ; } ) ; } }
Default publication method for entities.
Default publication method for entities .
// get the HoursCollection instance. /** This subscription publishes all documents regardless of user, but only if the logged in user is a volunteer. */ /** This subscription publishes all documents regardless of user, but only if the logged in user is the organization. */ // CHANGE ROLE.USER TO ORGANIZATION ONCE ROLE IS MADE /** This subscription publishes all documents regardless of user, but only if the logged in user is the Admin. */