1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-30 22:41:47 -05:00
shimapan/app/models/Invite.js

21 lines
506 B
JavaScript
Raw Normal View History

2017-10-11 12:55:46 -04:00
var mongoose = require('mongoose');
var InviteSchema = mongoose.Schema({
code: {
type: String,
unique: true,
required: true
},
2017-10-11 20:26:07 -04:00
scope: [String],
2017-10-11 12:55:46 -04:00
issuer: String,
recipient: String,
issued: Date,
used: Date,
exp: Date
});
InviteSchema.methods.use = function(canonicalname, cb) {
return this.model('Invite').updateOne({code: this.code}, {recipient: canonicalname, used: Date.now()}, cb);
};
2017-10-11 12:55:46 -04:00
module.exports = mongoose.model('Invite', InviteSchema);