2016-02-27 16:41:50 +09:00
|
|
|
import PublicationUtils from 'meteor/utilities:smart-publications';
|
2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-02-27 16:41:50 +09:00
|
|
|
|
2016-02-17 11:28:00 +09:00
|
|
|
Posts.addField([
|
|
|
|
/**
|
|
|
|
Count of the post's comments
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
fieldName: "commentCount",
|
|
|
|
fieldSchema: {
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
2016-04-14 09:54:41 +09:00
|
|
|
publish: true,
|
|
|
|
defaultValue: 0
|
2016-02-17 11:28:00 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
An array containing the `_id`s of commenters
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
fieldName: "commenters",
|
|
|
|
fieldSchema: {
|
|
|
|
type: [String],
|
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2016-02-17 19:39:43 +09:00
|
|
|
join: {
|
|
|
|
joinAs: "commentersArray",
|
2016-02-26 13:05:12 +09:00
|
|
|
collection: () => Users,
|
2016-02-25 17:44:43 +09:00
|
|
|
limit: 4
|
2016-02-17 19:39:43 +09:00
|
|
|
}
|
2016-02-17 11:28:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
2016-02-27 16:41:50 +09:00
|
|
|
PublicationUtils.addToFields(Posts.publishedFields.list, ["commentCount", "commenters"]);
|