30 lines
550 B
JavaScript
30 lines
550 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),
|
|
required: true
|
|
}
|
|
}, {
|
|
collection: 'rank',
|
|
timestamps: {createdAt: 'timestamp'}
|
|
});
|
|
// optional more indices
|
|
RankSchema.index({timestamp: 1});
|
|
|
|
module.exports = mongoose.model('Rank', RankSchema);
|