opt-cc/api/models/promotion.js

47 lines
911 B
JavaScript
Raw Normal View History

2017-06-09 18:30:35 +02:00
"use strict";
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const PromotionSchema = new Schema({
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
},
proposer: {
type: mongoose.Schema.Types.ObjectId,
ref: 'AppUser',
required: true
},
2017-06-10 13:16:15 +02:00
oldRankLvl: {
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
required: true
},
newRankLvl: {
2017-06-09 18:30:35 +02:00
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
required: true
},
confirmed: {
2017-06-10 13:16:15 +02:00
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
min: 0,
max: 2,
required: true
},
rejectReason: {
type: String
2017-06-09 18:30:35 +02:00
}
}, {
collection: 'promotion',
timestamps: {createdAt: 'timestamp'}
});
// optional more indices
PromotionSchema.index({timestamp: 1});
module.exports = mongoose.model('Promotion', PromotionSchema);