2017-10-11 12:55:46 -04:00
|
|
|
var mongoose = require('mongoose');
|
|
|
|
|
|
|
|
var InviteSchema = mongoose.Schema({
|
|
|
|
code: {
|
|
|
|
type: String,
|
|
|
|
unique: true,
|
|
|
|
required: true
|
|
|
|
},
|
2018-07-26 19:40:42 -04:00
|
|
|
|
|
|
|
scope: {
|
|
|
|
type: [String],
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
|
|
|
|
issuer: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
|
|
|
|
recipient: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
|
|
|
|
issued: {
|
|
|
|
type: Date,
|
|
|
|
default: Date.now
|
|
|
|
},
|
|
|
|
|
|
|
|
used: {
|
|
|
|
type: Date,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
|
2018-07-27 14:23:23 -04:00
|
|
|
expires: {
|
2018-07-26 19:40:42 -04:00
|
|
|
type: Date,
|
|
|
|
default: null
|
|
|
|
}
|
2017-10-11 12:55:46 -04:00
|
|
|
});
|
|
|
|
|
2018-07-25 01:45:05 -04:00
|
|
|
/*InviteSchema.methods.use = function(canonicalname, cb) {
|
2018-01-15 15:29:32 -05:00
|
|
|
return this.model('Invite').updateOne({code: this.code}, {recipient: canonicalname, used: Date.now()}, cb);
|
2018-07-25 01:45:05 -04:00
|
|
|
};*/
|
2018-01-15 15:29:32 -05:00
|
|
|
|
2017-10-11 12:55:46 -04:00
|
|
|
module.exports = mongoose.model('Invite', InviteSchema);
|