opt-cc/server/models/rank.js

30 lines
559 B
JavaScript
Raw Permalink 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 RankSchema = 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
},
level: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
2017-05-10 11:04:06 +02:00
}, {
collection: 'rank',
2018-03-12 09:26:44 +01:00
timestamps: {createdAt: 'timestamp'},
2017-05-10 11:04:06 +02:00
});
// optional more indices
RankSchema.index({timestamp: 1});
module.exports = mongoose.model('Rank', RankSchema);