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-11-08 16:33:25 +09:00
|
|
|
Users.addField([
|
|
|
|
/**
|
|
|
|
Count of the user's comments
|
|
|
|
*/
|
|
|
|
{
|
2017-01-18 10:18:33 +09:00
|
|
|
fieldName: "commentCount",
|
2016-11-08 16:33:25 +09:00
|
|
|
fieldSchema: {
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
|
|
|
publish: true,
|
|
|
|
defaultValue: 0,
|
2016-12-06 10:55:47 +01:00
|
|
|
viewableBy: ['guests'],
|
2016-11-08 16:33:25 +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,
|
2016-10-30 18:25:51 +01:00
|
|
|
defaultValue: 0,
|
2016-12-06 10:55:47 +01:00
|
|
|
viewableBy: ['guests'],
|
2016-02-17 11:28:00 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
An array containing the `_id`s of commenters
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
fieldName: "commenters",
|
|
|
|
fieldSchema: {
|
2017-01-11 18:02:12 +01:00
|
|
|
type: [String],
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2017-01-11 18:02:12 +01:00
|
|
|
// join: {
|
|
|
|
// joinAs: "commentersArray",
|
|
|
|
// collection: () => Users,
|
|
|
|
// limit: 4
|
|
|
|
// },
|
2016-11-08 14:56:39 +09:00
|
|
|
resolveAs: 'commenters: [User]',
|
2016-12-06 10:55:47 +01:00
|
|
|
viewableBy: ['guests'],
|
2016-02-17 11:28:00 +09:00
|
|
|
}
|
2017-01-11 18:02:12 +01:00
|
|
|
}
|
2016-02-17 11:28:00 +09:00
|
|
|
]);
|