'use strict'; const mongoose = require('mongoose'); const Schema = mongoose.Schema; 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, } }, { collection: 'logBudget', versionKey: false, }); // optional more indices LogBudgetSchema.index({war: 1}); module.exports = mongoose.model('LogBudget', LogBudgetSchema);