2017-05-10 11:04:06 +02:00
|
|
|
"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),
|
2017-05-13 23:49:17 +02:00
|
|
|
default: 0
|
2017-05-10 11:04:06 +02:00
|
|
|
},
|
|
|
|
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);
|