33 lines
604 B
JavaScript
33 lines
604 B
JavaScript
|
"use strict";
|
||
|
|
||
|
const mongoose = require('mongoose');
|
||
|
const Schema = mongoose.Schema;
|
||
|
|
||
|
const UserSchema = new Schema({
|
||
|
username: {
|
||
|
type: String,
|
||
|
required: true,
|
||
|
unique: true
|
||
|
},
|
||
|
rankLvl: {
|
||
|
type: Number,
|
||
|
get: v => Math.round(v),
|
||
|
set: v => Math.round(v),
|
||
|
default: 0,
|
||
|
min: 0,
|
||
|
max: 22
|
||
|
},
|
||
|
squadId: {
|
||
|
type: mongoose.Schema.Types.ObjectId,
|
||
|
ref: 'Squad',
|
||
|
default: null
|
||
|
}
|
||
|
}, {
|
||
|
collection: 'user',
|
||
|
timestamps: {createdAt: 'timestamp'}
|
||
|
});
|
||
|
// optional more indices
|
||
|
UserSchema.index({timestamp: 1});
|
||
|
|
||
|
module.exports = mongoose.model('User', UserSchema);
|