From e8399184f0f6bd77141c03f28902af69028afd2f Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Thu, 22 Sep 2016 14:09:53 +0200 Subject: [PATCH] Step 10.9: Limit data sent to the client --- server/imports/publications/parties.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/server/imports/publications/parties.ts b/server/imports/publications/parties.ts index 08ef863ef..b7652bbb9 100644 --- a/server/imports/publications/parties.ts +++ b/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); +});