Skip to content

Instantly share code, notes, and snippets.

@dai-shi
Last active March 28, 2016 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dai-shi/98b893f5f4bc63f6011f to your computer and use it in GitHub Desktop.
Save dai-shi/98b893f5f4bc63f6011f to your computer and use it in GitHub Desktop.
diff --git a/imports/api/tasks.js b/imports/api/tasks.js
index f1d2c92..441feee 100644
--- a/imports/api/tasks.js
+++ b/imports/api/tasks.js
@@ -6,8 +6,14 @@ export const Tasks = new Mongo.Collection('tasks');
if (Meteor.isServer) {
// This code only runs on the server
+ // Only publish tasks that are public or belong to the current user
Meteor.publish('tasks', function tasksPublication() {
- return Tasks.find();
+ return Tasks.find({
+ $or: [
+ { private: { $ne: true } },
+ { owner: this.userId },
+ ],
+ });
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment