Skip to content

Instantly share code, notes, and snippets.

@dai-shi
Created March 28, 2016 08:05
Show Gist options
  • Save dai-shi/40f9e3037c61844e19c1 to your computer and use it in GitHub Desktop.
Save dai-shi/40f9e3037c61844e19c1 to your computer and use it in GitHub Desktop.
diff --git a/imports/api/tasks.js b/imports/api/tasks.js
index 0201eb4..234a839 100644
--- a/imports/api/tasks.js
+++ b/imports/api/tasks.js
@@ -4,6 +4,13 @@ import { check } from 'meteor/check';
export const Tasks = new Mongo.Collection('tasks');
+if (Meteor.isServer) {
+ // This code only runs on the server
+ Meteor.publish('tasks', function tasksPublication() {
+ return Tasks.find();
+ });
+}
+
Meteor.methods({
'tasks.insert'(text) {
check(text, String);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment