opt-cc/api/models/squad.js

30 lines
559 B
JavaScript
Raw Permalink Normal View History

2017-05-10 11:04:06 +02:00
"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);