2017-05-10 11:04:06 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
const AwardingSchema = new Schema({
|
|
|
|
userId: {
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
ref: 'User'
|
|
|
|
},
|
|
|
|
decorationId: {
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
ref: 'Decoration'
|
|
|
|
},
|
|
|
|
reason: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
2017-06-09 18:30:35 +02:00
|
|
|
proposer: {
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
ref: 'AppUser',
|
|
|
|
required: true
|
|
|
|
},
|
2017-05-10 11:04:06 +02:00
|
|
|
confirmed: {
|
2017-06-10 22:07:32 +02:00
|
|
|
type: Number,
|
|
|
|
get: v => Math.round(v),
|
|
|
|
set: v => Math.round(v),
|
|
|
|
min: 0,
|
|
|
|
max: 2,
|
|
|
|
default: 0
|
2017-05-10 11:04:06 +02:00
|
|
|
},
|
2018-03-11 13:52:26 +01:00
|
|
|
rejectReason: {
|
|
|
|
type: String
|
|
|
|
},
|
2017-05-10 11:04:06 +02:00
|
|
|
date: {
|
|
|
|
type: Date,
|
|
|
|
default: Date.now()
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
collection: 'awarding',
|
|
|
|
timestamps: {createdAt: 'timestamp'}
|
|
|
|
});
|
|
|
|
// optional more indices
|
|
|
|
AwardingSchema.index({timestamp: 1});
|
|
|
|
|
|
|
|
module.exports = mongoose.model('Awarding', AwardingSchema);
|