opt-cc/api/models/decoration.js

35 lines
707 B
JavaScript
Raw Normal View History

2018-03-12 09:26:44 +01:00
'use strict';
2017-05-10 11:04:06 +02:00
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const DecorationSchema = new Schema({
name: {
type: String,
2018-03-12 09:26:44 +01:00
required: true,
2017-05-10 11:04:06 +02:00
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR', 'GLOBAL'],
2018-03-12 09:26:44 +01:00
required: true,
2017-05-10 11:04:06 +02:00
},
description: {
type: String,
2018-03-12 09:26:44 +01:00
required: true,
2017-05-10 11:04:06 +02:00
},
sortingNumber: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
default: 0,
2017-05-10 11:04:06 +02:00
},
2018-03-12 09:26:44 +01:00
isMedal: {type: Boolean, required: true},
2017-05-10 11:04:06 +02:00
}, {
collection: 'decoration',
2018-03-12 09:26:44 +01:00
timestamps: {createdAt: 'timestamp'},
2017-05-10 11:04:06 +02:00
});
// optional more indices
DecorationSchema.index({timestamp: 1});
module.exports = mongoose.model('Decoration', DecorationSchema);