2017-07-08 15:34:36 +02:00
|
|
|
"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
|
|
|
|
},
|
|
|
|
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
|
|
|
|
},
|
2017-08-05 23:19:23 +02:00
|
|
|
revive: {
|
|
|
|
type: Number,
|
|
|
|
get: v => Math.round(v),
|
|
|
|
set: v => Math.round(v),
|
|
|
|
required: true
|
|
|
|
},
|
2017-07-08 15:34:36 +02:00
|
|
|
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),
|
2017-08-05 23:19:23 +02:00
|
|
|
required: true
|
2017-07-08 15:34:36 +02:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
collection: 'player',
|
|
|
|
timestamps: {createdAt: 'timestamp'}
|
|
|
|
});
|
|
|
|
// optional more indices
|
|
|
|
PlayerSchema.index({timestamp: 1});
|
|
|
|
|
|
|
|
module.exports = mongoose.model('Player', PlayerSchema);
|