Vulcan/packages/nova-comments/lib/custom_fields.js

36 lines
708 B
JavaScript
Raw Normal View History

import PublicationUtils from 'meteor/utilities:smart-publications';
2016-06-23 11:40:35 +09:00
import Posts from "meteor/nova:posts";
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,
publish: true,
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 11:28:00 +09:00
}
}
]);
PublicationUtils.addToFields(Posts.publishedFields.list, ["commentCount", "commenters"]);