opt-cc/api/models/logs/points.js

40 lines
774 B
JavaScript

'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const LogKillSchema = new Schema({
war: {
type: mongoose.Schema.Types.ObjectId,
ref: 'War',
required: true,
},
time: {
type: Date,
required: true,
},
ptBlufor: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
ptOpfor: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR', 'NONE'],
required: true,
},
}, {
collection: 'logPoints',
});
// optional more indices
LogKillSchema.index({war: 1, shooter: 1, target: 1});
module.exports = mongoose.model('LogPoints', LogKillSchema);