opt-cc/api/models/rank.js

32 lines
575 B
JavaScript

"use strict";
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const RankSchema = new Schema({
name: {
type: String,
required: true
},
fraction: {
type: String,
enum: ['BLUFOR', 'OPFOR'],
required: true
},
level: {
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
min: 0,
max: 22,
required: true
}
}, {
collection: 'rank',
timestamps: {createdAt: 'timestamp'}
});
// optional more indices
RankSchema.index({timestamp: 1});
module.exports = mongoose.model('Rank', RankSchema);