publications.js 584 B

123456789101112131415161718192021222324252627
  1. Meteor.publish('posts', function (options) {
  2. // It would probably be safer to pass sort and limit as 2 separate params.
  3. check(options, {
  4. sort: Object,
  5. limit: Number
  6. });
  7. return Posts.find({}, options);
  8. });
  9. Meteor.publish('singlePost', function (postId) {
  10. check(postId, String);
  11. return Posts.find(postId);
  12. });
  13. Meteor.publish('comments', function (postId) {
  14. check(postId, String);
  15. return Comments.find({
  16. postId: postId
  17. });
  18. });
  19. Meteor.publish('notifications', function () {
  20. return Notifications.find({
  21. userId: this.userId,
  22. read: false
  23. });
  24. });