opt-cc/server/models/promotion.js

47 lines
931 B
JavaScript
Raw Normal View History

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