|
@@ -39,6 +39,7 @@ module.exports = function(crowi) {
|
|
|
creator: { type: ObjectId, ref: 'User', index: true },
|
|
creator: { type: ObjectId, ref: 'User', index: true },
|
|
|
liker: [{ type: ObjectId, ref: 'User', index: true }],
|
|
liker: [{ type: ObjectId, ref: 'User', index: true }],
|
|
|
seenUsers: [{ type: ObjectId, ref: 'User', index: true }],
|
|
seenUsers: [{ type: ObjectId, ref: 'User', index: true }],
|
|
|
|
|
+ commentCount: { type: Number, default: 0 },
|
|
|
createdAt: { type: Date, default: Date.now },
|
|
createdAt: { type: Date, default: Date.now },
|
|
|
updatedAt: Date
|
|
updatedAt: Date
|
|
|
});
|
|
});
|
|
@@ -164,6 +165,22 @@ module.exports = function(crowi) {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ pageSchema.statics.updateCommentCount = function (page, num)
|
|
|
|
|
+ {
|
|
|
|
|
+ var self = this;
|
|
|
|
|
+
|
|
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
|
|
+ self.update({_id: page}, {commentCount: num}, {}, function(err, data) {
|
|
|
|
|
+ if (err) {
|
|
|
|
|
+ debug('Update commentCount Error', err);
|
|
|
|
|
+ return reject(err);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resolve(data);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
pageSchema.statics.getGrantLabels = function() {
|
|
pageSchema.statics.getGrantLabels = function() {
|
|
|
var grantLabels = {};
|
|
var grantLabels = {};
|
|
|
grantLabels[GRANT_PUBLIC] = '公開';
|
|
grantLabels[GRANT_PUBLIC] = '公開';
|