31 lines
572 B
JavaScript
31 lines
572 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,
|
||
|
max: 22,
|
||
|
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);
|