2018-03-12 09:26:44 +01:00
|
|
|
'use strict';
|
2017-07-08 15:34:36 +02:00
|
|
|
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
const WarSchema = new Schema({
|
2017-07-08 22:50:01 +02:00
|
|
|
title: {
|
|
|
|
type: String,
|
2018-03-12 09:26:44 +01:00
|
|
|
required: true,
|
2017-07-08 22:50:01 +02:00
|
|
|
},
|
2017-07-08 15:34:36 +02:00
|
|
|
date: {
|
|
|
|
type: Date,
|
|
|
|
},
|
2018-02-26 09:04:27 +01:00
|
|
|
endDate: {
|
2017-10-30 08:59:08 +01:00
|
|
|
type: Date,
|
|
|
|
},
|
2019-10-01 13:51:03 +02:00
|
|
|
fractionMappingBlufor: {
|
|
|
|
type: String,
|
|
|
|
enum: ['BLUFOR', 'OPFOR', 'ARF', 'SWORD'],
|
|
|
|
default: 'BLUFOR',
|
|
|
|
},
|
|
|
|
fractionMappingOpfor: {
|
|
|
|
type: String,
|
|
|
|
enum: ['BLUFOR', 'OPFOR', 'ARF', 'SWORD'],
|
|
|
|
default: 'OPFOR',
|
|
|
|
},
|
2017-07-08 15:34:36 +02:00
|
|
|
ptBlufor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
2017-07-08 15:34:36 +02:00
|
|
|
},
|
|
|
|
ptOpfor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
2017-07-08 15:34:36 +02:00
|
|
|
},
|
2017-07-30 08:55:14 +02:00
|
|
|
playersBlufor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
default: 0,
|
2017-07-30 08:55:14 +02:00
|
|
|
},
|
|
|
|
playersOpfor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
default: 0,
|
2017-08-12 16:28:18 +02:00
|
|
|
},
|
|
|
|
campaign: {
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
2017-10-21 12:11:32 +02:00
|
|
|
ref: 'Campaign',
|
2018-03-12 09:26:44 +01:00
|
|
|
required: true,
|
2017-10-21 12:11:32 +02:00
|
|
|
},
|
|
|
|
budgetBlufor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
default: 0,
|
2017-10-21 12:11:32 +02:00
|
|
|
},
|
|
|
|
budgetOpfor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
default: 0,
|
2017-10-21 12:11:32 +02:00
|
|
|
},
|
|
|
|
endBudgetBlufor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
default: 0,
|
2017-10-21 12:11:32 +02:00
|
|
|
},
|
|
|
|
endBudgetOpfor: {
|
|
|
|
type: Number,
|
2018-03-12 09:26:44 +01:00
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
default: 0,
|
|
|
|
},
|
2017-07-08 15:34:36 +02:00
|
|
|
}, {
|
|
|
|
collection: 'war',
|
2018-03-12 09:26:44 +01:00
|
|
|
timestamps: {createdAt: 'timestamp'},
|
2017-07-08 15:34:36 +02:00
|
|
|
});
|
|
|
|
// optional more indices
|
|
|
|
WarSchema.index({timestamp: 1});
|
|
|
|
|
|
|
|
module.exports = mongoose.model('War', WarSchema);
|