106 lines
2.0 KiB
JavaScript
106 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
const mongoose = require('mongoose');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const PlayerSchema = new Schema({
|
|
name: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
fraction: {
|
|
type: String,
|
|
enum: ['BLUFOR', 'OPFOR'],
|
|
required: true,
|
|
},
|
|
warId: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'War',
|
|
required: true,
|
|
},
|
|
kill: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
vehicleLight: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
vehicleHeavy: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
vehicleAir: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
death: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
friendlyFire: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
revive: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
respawn: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
flagTouch: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: true,
|
|
},
|
|
steamUUID: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
},
|
|
performance: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'LogServerFpsSchema',
|
|
required: false,
|
|
},
|
|
travelDistance: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: false,
|
|
},
|
|
driverDistance: {
|
|
type: Number,
|
|
get: (v) => Math.round(v),
|
|
set: (v) => Math.round(v),
|
|
required: false,
|
|
},
|
|
},
|
|
{
|
|
collection: 'player',
|
|
timestamps: {createdAt: 'timestamp'},
|
|
});
|
|
// optional more indices
|
|
PlayerSchema.index({warId: 1});
|
|
|
|
module.exports = mongoose.model('Player', PlayerSchema);
|