2018-03-12 09:26:44 +01:00
|
|
|
'use strict';
|
2017-10-21 18:23:04 +02:00
|
|
|
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
2019-02-17 13:02:35 +01:00
|
|
|
const LogBudgetSchema = new Schema(
|
|
|
|
{
|
|
|
|
war: {
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
ref: 'War',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
time: {
|
|
|
|
type: Date,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
fraction: {
|
|
|
|
type: String,
|
|
|
|
enum: ['BLUFOR', 'OPFOR'],
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
oldBudget: {
|
|
|
|
type: Number,
|
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
newBudget: {
|
|
|
|
type: Number,
|
|
|
|
get: (v) => Math.round(v),
|
|
|
|
set: (v) => Math.round(v),
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
buy: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
player: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
item: {
|
|
|
|
type: String,
|
2019-02-17 13:03:35 +01:00
|
|
|
},
|
2017-10-21 18:23:04 +02:00
|
|
|
},
|
2019-02-17 13:02:35 +01:00
|
|
|
{
|
|
|
|
collection: 'logBudget',
|
|
|
|
versionKey: false,
|
|
|
|
});
|
2017-10-21 18:23:04 +02:00
|
|
|
// optional more indices
|
|
|
|
LogBudgetSchema.index({war: 1});
|
|
|
|
|
|
|
|
module.exports = mongoose.model('LogBudget', LogBudgetSchema);
|