2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-06-23 15:00:58 +09:00
|
|
|
import Users from "meteor/nova:users";
|
2016-02-27 16:41:50 +09:00
|
|
|
|
2016-10-30 18:25:51 +01:00
|
|
|
const alwaysPublic = user => true;
|
|
|
|
|
2016-11-08 16:33:25 +09:00
|
|
|
Users.addField([
|
|
|
|
/**
|
|
|
|
Count of the user's comments
|
|
|
|
*/
|
|
|
|
{
|
2016-11-10 14:22:47 +01:00
|
|
|
fieldName: "__commentCount",
|
2016-11-08 16:33:25 +09:00
|
|
|
fieldSchema: {
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
|
|
|
publish: true,
|
|
|
|
defaultValue: 0,
|
|
|
|
viewableIf: alwaysPublic,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
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,
|
2016-10-30 18:25:51 +01:00
|
|
|
defaultValue: 0,
|
|
|
|
viewableIf: alwaysPublic,
|
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-10-30 18:25:51 +01:00
|
|
|
},
|
2016-11-08 14:56:39 +09:00
|
|
|
resolveAs: 'commenters: [User]',
|
2016-10-30 18:25:51 +01:00
|
|
|
viewableIf: alwaysPublic,
|
2016-02-17 11:28:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|