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

42 lines
770 B
JavaScript

'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const LogTransportSchema = new Schema({
war: {
type: mongoose.Schema.Types.ObjectId,
ref: 'War',
required: true,
},
time: {
type: Date,
required: true,
},
driver: {
type: String,
required: true,
},
passenger: {
type: String,
required: true,
},
distance: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR'],
required: true,
},
}, {
collection: 'logTransport',
});
// optional more indices
LogTransportSchema.index({war: 1, driver: 1});
module.exports = mongoose.model('LogTransport', LogTransportSchema);