opt-cc/api/models/squad.js

30 lines
568 B
JavaScript
Raw Normal View History

2018-03-12 09:26:44 +01:00
'use strict';
2017-05-10 11:04:06 +02:00
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const SquadSchema = new Schema({
name: {
type: String,
2018-03-12 09:26:44 +01:00
required: true,
2017-05-10 11:04:06 +02:00
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR'],
2018-03-12 09:26:44 +01:00
required: true,
2017-05-10 11:04:06 +02:00
},
sortingNumber: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
default: 0,
},
2017-05-10 11:04:06 +02:00
}, {
collection: 'squad',
2018-03-12 09:26:44 +01:00
timestamps: {createdAt: 'timestamp'},
2017-05-10 11:04:06 +02:00
});
// optional more indices
SquadSchema.index({timestamp: 1});
module.exports = mongoose.model('Squad', SquadSchema);