publish() {
    if (Meteor.isServer) {
      // get the OpportunityCollection instance.
      const instance = this;
      /**
       * This subscription publishes all documents for volunteer.
       */
      Meteor.publish(OpportunityPublications.opportunity, function publish() {
        return instance._collection.find();
        // return this.ready();
      });

      /**
       * This subscription publishes documents that belong to logged-in organization who can access define, update and removeIt.
       */
      Meteor.publish(OpportunityPublications.opportunityOrg, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.VOLUNTEER)) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ organization: username });
        }
        return this.ready();
      });

      /**
       *This subscription publishes all documents for Admin who can access define, update and removeIt.
       */
      Meteor.publish(OpportunityPublications.opportunityAdmin, 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(OpportunityPublications.opportunity, function publish() {
        return instance._collection.find();
      });
      Meteor.publish(OpportunityPublications.opportunityOrg, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, ROLE.VOLUNTEER)) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ organization: username });
        }
        return this.ready();
      });
      Meteor.publish(OpportunityPublications.opportunityAdmin, 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 ( OpportunityPublications . opportunity , function publish ( ) { return instance . _collection . find ( ) ; } ) ; Meteor . publish ( OpportunityPublications . opportunityOrg , function publish ( ) { if ( this . userId && Roles . userIsInRole ( this . userId , ROLE . VOLUNTEER ) ) { const username = Meteor . users . findOne ( this . userId ) . username ; return instance . _collection . find ( { organization : username } ) ; } return this . ready ( ) ; } ) ; Meteor . publish ( OpportunityPublications . opportunityAdmin , 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 OpportunityCollection instance. /**
       * This subscription publishes all documents for volunteer.
       */ // return this.ready(); /**
       * This subscription publishes documents that belong to logged-in organization who can access define, update and removeIt.
       */ /**
       *This subscription publishes all documents for Admin who can access define, update and removeIt.
       */