update api errormanager
This commit is contained in:
@@ -7,9 +7,13 @@ const tokenSchema = mongoose.Schema({
|
||||
default: Date.now
|
||||
}
|
||||
});
|
||||
// tokenSchema.method.clearExpire = function(cb) {
|
||||
// return this.model('token').remove({ expire: { $lte: Date.now() } }, cb);
|
||||
// }
|
||||
tokenSchema.statics.clearExpire = function(cb) {
|
||||
console.log(Date.now())
|
||||
return this.remove({ expire: { $lte: Date.now() } }, cb);
|
||||
}
|
||||
tokenSchema.statics.renewToken = function(id, expire, cb) {
|
||||
return this.update({ _id: mongoose.Schema.Types.ObjectId(id) }, { $set: { expire: Date.now() + 86400000 } }, cb);
|
||||
}
|
||||
|
||||
const token = mongoose.model('token', tokenSchema, 'token');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user