app/imports/api/trip/TripCollection.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(tripPublications.trip, function publish() {
        if (this.userId) {
          const username = Meteor.users.findOne(this.userId).username;
          const county = Meteor.users.findOne(this.userId).profile.county;
          return instance._collection.find({ owner: username, county: county });
        }
        return this.ready();
      });
      Meteor.publish(tripPublications.tripCommunity, function publish() {
        if (this.userId) {
          return instance._collection.find();
        }
        return this.ready();
      });
    }
  }
publish ( ) { if ( Meteor . isServer ) { const instance = this ; Meteor . publish ( tripPublications . trip , function publish ( ) { if ( this . userId ) { const username = Meteor . users . findOne ( this . userId ) . username ; const county = Meteor . users . findOne ( this . userId ) . profile . county ; return instance . _collection . find ( { owner : username , county : county } ) ; } return this . ready ( ) ; } ) ; Meteor . publish ( tripPublications . tripCommunity , function publish ( ) { if ( this . userId ) { 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. */