opt-cc/api/models/player.js

93 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-03-12 09:26:44 +01:00
'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const PlayerSchema = new Schema({
name: {
type: String,
2018-03-12 09:26:44 +01:00
required: true,
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR'],
2018-03-12 09:26:44 +01:00
required: true,
},
warId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'War',
2018-03-12 09:26:44 +01:00
required: true,
},
kill: {
type: Number,
2018-03-12 09:26:44 +01:00
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,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
death: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
friendlyFire: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
2017-08-05 23:19:23 +02:00
revive: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
2017-08-05 23:19:23 +02:00
},
respawn: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
flagTouch: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
sort: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
2018-02-26 09:33:28 +01:00
},
steamUUID: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
},
}, {
collection: 'player',
2018-03-12 09:26:44 +01:00
timestamps: {createdAt: 'timestamp'},
});
// optional more indices
2018-02-26 09:33:28 +01:00
PlayerSchema.index({warId: 1});
module.exports = mongoose.model('Player', PlayerSchema);