From 17b4a9e8edc5acf50990acd44b9163173e7e5493 Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Thu, 7 Apr 2016 12:14:30 +0200 Subject: [PATCH] Step 9.2: Add the `parties` publication to the server --- imports/api/parties/publish.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 imports/api/parties/publish.js diff --git a/imports/api/parties/publish.js b/imports/api/parties/publish.js new file mode 100644 index 000000000..590f23bc6 --- /dev/null +++ b/imports/api/parties/publish.js @@ -0,0 +1,31 @@ +import { Meteor } from 'meteor/meteor'; + +import { Parties } from './collection'; + +if (Meteor.isServer) { + Meteor.publish('parties', function() { + const selector = { + $or: [{ + // the public parties + $and: [{ + public: true + }, { + public: { + $exists: true + } + }] + }, { + // when logged in user is the owner + $and: [{ + owner: this.userId + }, { + owner: { + $exists: true + } + }] + }] + }; + + return Parties.find(selector); + }); +}