Permalink
Browse files

修复帖子修改时间的bug

  • Loading branch information...
1 parent 32856e6 commit 8add8cd9d1c3a0a3a602a3f69004e332775921ec @alsotang alsotang committed Sep 12, 2016
Showing with 8 additions and 6 deletions.
  1. +1 −0 controllers/reply.js
  2. +1 −0 controllers/topic.js
  3. +0 −6 models/base_model.js
  4. +6 −0 models/user.js
@@ -139,6 +139,7 @@ exports.update = function (req, res, next) {
if (content.trim().length > 0) {
reply.content = content;
+ reply.update_at = new Date();
reply.save(function (err) {
if (err) {
return next(err);
@@ -241,6 +241,7 @@ exports.update = function (req, res, next) {
topic.title = title;
topic.content = content;
topic.tab = tab;
+ topic.update_at = new Date();
topic.save(function (err) {
if (err) {
@@ -12,10 +12,4 @@ module.exports = function (schema) {
schema.methods.update_at_ago = function () {
return tools.formatDate(this.update_at, true);
};
-
- schema.pre('save', function(next){
- var now = new Date();
- this.update_at = now;
- next();
- });
};
View
@@ -76,4 +76,10 @@ UserSchema.index({score: -1});
UserSchema.index({githubId: 1});
UserSchema.index({accessToken: 1});
+UserSchema.pre('save', function(next){
+ var now = new Date();
+ this.update_at = now;
+ next();
+});
+
mongoose.model('User', UserSchema);

0 comments on commit 8add8cd

Please sign in to comment.