Skip to content

Instantly share code, notes, and snippets.

@johanbrook
Last active January 15, 2016 12:50
Show Gist options
  • Save johanbrook/a347c2b65a0c7c76237d to your computer and use it in GitHub Desktop.
Save johanbrook/a347c2b65a0c7c76237d to your computer and use it in GitHub Desktop.

Revisions

  1. johanbrook revised this gist Jan 15, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion publication.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Meteor.publish('nightclub', (nightClubId) => {
    check(nightClubId, String);

    const clubFields = {name: 1, managers: 1};
    const managerFields : {profile: 1, emails: 1};
    const managerFields = {profile: 1, emails: 1};

    const clubCursor = Nightclubs.find(nightClubId, {limit: 1, fields: clubFields});
    const managerIds = _.pluck(clubCursor.fetch(), 'managers');
  2. johanbrook revised this gist Jan 15, 2016. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions publication.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    Meteor.publish('nightclub', (nightClubId) => {
    check(nightClubId, String);

    const clubFields = {name: 1, managers: 1};
    const managerFields : {profile: 1, emails: 1};

    const clubCursor = Nightclubs.find(nightClubId, {limit: 1});
    const clubCursor = Nightclubs.find(nightClubId, {limit: 1, fields: clubFields});
    const managerIds = _.pluck(clubCursor.fetch(), 'managers');

    const managersCursor = Meteor.users.find({_id: {$in: managerIds}});
    const managersCursor = Meteor.users.find({_id: {$in: managerIds}}, {fields: managerFields});

    return [clubCursor, managersCursor];
    });
  3. johanbrook created this gist Jan 15, 2016.
    10 changes: 10 additions & 0 deletions publication.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    Meteor.publish('nightclub', (nightClubId) => {
    check(nightClubId, String);

    const clubCursor = Nightclubs.find(nightClubId, {limit: 1});
    const managerIds = _.pluck(clubCursor.fetch(), 'managers');

    const managersCursor = Meteor.users.find({_id: {$in: managerIds}});

    return [clubCursor, managersCursor];
    });