app/imports/api/user/UserCollection.js
/**
   * Default publication method for entities.
   * It publishes the entire collection for admin and just the trip associated to an owner.
   */
Default publication method for entities.
It publishes the entire collection for admin and just the trip associated to an owner.
Default publication method for entities . It publishes the entire collection for admin and just the trip associated to an owner .
publish() {
    if (Meteor.isServer) {
      const instance = this;
      Meteor.publish(userPublications.user, function publish() {
        if (this.userId) {
          const username = Meteor.users.findOne(this.userId).username;
          return instance._collection.find({ username: username });
        }
        return this.ready();
      });
      Meteor.publish(userPublications.userAdmin, function publish() {
        if (this.userId && Roles.userIsInRole(this.userId, 'admin')) {
          return instance._collection.find();
        }
        return this.ready();
      });
    }
  }
publish ( ) { if ( Meteor . isServer ) { const instance = this ; Meteor . publish ( userPublications . user , function publish ( ) { if ( this . userId ) { const username = Meteor . users . findOne ( this . userId ) . username ; return instance . _collection . find ( { username : username } ) ; } return this . ready ( ) ; } ) ; Meteor . publish ( userPublications . userAdmin , function publish ( ) { if ( this . userId && Roles . userIsInRole ( this . userId , 'admin' ) ) { return instance . _collection . find ( ) ; } return this . ready ( ) ; } ) ; } }
Default publication method for entities.
Default publication method for entities .
// get the TripCollection instance. /** This subscription publishes only the documents associated with the logged in user */ /** This subscription publishes all documents regardless of user, but only if the logged in user is the Admin. */