add mongodb access lib

This commit is contained in:
Jay
2017-06-02 22:53:34 +08:00
parent c69679dfe2
commit e0dcf3bd6c
6 changed files with 180 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
const mongoose = require('mongoose');
const tokenSchema = mongoose.Schema({
object: Object,
expire: {
type: Number,
default: Date.now
}
});
// tokenSchema.method.clearExpire = function(cb) {
// return this.model('token').remove({ expire: { $lte: Date.now() } }, cb);
// }
const token = mongoose.model('token', tokenSchema, 'token');
module.exports = {
token
}