Permalink
Browse files

Made a simple publication/subscription for comments.

chapter10-4
  • Loading branch information...
tmeasday committed Apr 8, 2013
1 parent 1f82c0a commit 944cb078ee4534061bfea9775852b5cf7563bd97
Showing with 8 additions and 4 deletions.
  1. +4 −1 lib/router.js
  2. +4 −3 server/publications.js
View
@@ -3,14 +3,17 @@ Router.configure({
loadingTemplate: 'loading',
notFoundTemplate: 'notFound',
waitOn: function() {
- return [Meteor.subscribe('posts'), Meteor.subscribe('comments')];
+ return Meteor.subscribe('posts');
}
});
Router.route('/', {name: 'postsList'});
Router.route('/posts/:_id', {
name: 'postPage',
+ waitOn: function() {
+ return Meteor.subscribe('comments', this.params._id);
+ },
data: function() { return Posts.findOne(this.params._id); }
});
View
@@ -2,6 +2,7 @@ Meteor.publish('posts', function() {
return Posts.find();
});
-Meteor.publish('comments', function() {
- return Comments.find();
-})
+Meteor.publish('comments', function(postId) {
+ check(postId, String);
+ return Comments.find({postId: postId});
+});

0 comments on commit 944cb07

Please sign in to comment.