forked from mantrajs/mantra-sample-blog-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
posts.js
29 lines (25 loc) · 724 Bytes
/
posts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {Posts, Comments} from '/lib/collections';
import {Meteor} from 'meteor/meteor';
import {check} from 'meteor/check';
import {uuid} from '/lib/match';
export default function () {
Meteor.publish('posts.list', function () {
const selector = {};
const options = {
fields: {_id: 1, title: 1},
sort: {createdAt: -1},
limit: 10
};
return Posts.find(selector, options);
});
Meteor.publish('posts.single', function (postId) {
check(postId, uuid);
const selector = {_id: postId};
return Posts.find(selector);
});
Meteor.publish('posts.comments', function (postId) {
check(postId, uuid);
const selector = {postId};
return Comments.find(selector);
});
}