v3: misc fixes

This commit is contained in:
Matteo Pagliazzi
2016-05-15 14:20:20 +02:00
parent 164c024512
commit 3fbc156811
19 changed files with 33 additions and 48 deletions

View File

@@ -32,6 +32,10 @@ module.exports = function baseModel (schema, options = {}) {
if (!this.isNew) this.updatedAt = Date.now();
next();
});
schema.pre('update', function preUpdateModel () {
this.update({}, { $set: { updatedAt: new Date() } });
});
}
let noSetFields = ['createdAt', 'updatedAt'];