opt-cc/server/models/squad.js

30 lines
568 B
JavaScript

'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const SquadSchema = new Schema({
name: {
type: String,
required: true,
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR'],
required: true,
},
sortingNumber: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
default: 0,
},
}, {
collection: 'squad',
timestamps: {createdAt: 'timestamp'},
});
// optional more indices
SquadSchema.index({timestamp: 1});
module.exports = mongoose.model('Squad', SquadSchema);