Permalink
Browse files

Step 10.9: Limit data sent to the client

  • Loading branch information...
1 parent a76d857 commit e8399184f0f6bd77141c03f28902af69028afd2f @kamilkisiela kamilkisiela committed with DAB0mB Sep 22, 2016
Showing with 21 additions and 1 deletion.
  1. +21 −1 server/imports/publications/parties.ts
@@ -1,4 +1,24 @@
import { Meteor } from 'meteor/meteor';
import { Parties } from '../../../both/collections/parties.collection';
-Meteor.publish('parties', () => Parties.find());
+Meteor.publish('parties', function() {
+ const selector = {
+ $or: [{
+ // party is public
+ public: true
+ },
+ // or
+ {
+ // current user is the owner
+ $and: [{
+ owner: this.userId
+ }, {
+ owner: {
+ $exists: true
+ }
+ }]
+ }]
+ };
+
+ return Parties.find(selector);
+});

0 comments on commit e839918

Please sign in to comment.