opt-cc/server/models/user.js

31 lines
588 B
JavaScript
Raw 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 UserSchema = new Schema({
username: {
type: String,
required: true,
2018-03-12 09:26:44 +01:00
unique: true,
2017-05-10 11:04:06 +02:00
},
rankLvl: {
type: Number,
2018-03-12 09:26:44 +01:00
get: (v) => Math.round(v),
set: (v) => Math.round(v),
default: 0,
2017-05-10 11:04:06 +02:00
},
squadId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Squad',
2018-03-12 09:26:44 +01:00
default: null,
},
2017-05-10 11:04:06 +02:00
}, {
collection: 'user',
2018-03-12 09:26:44 +01:00
timestamps: {createdAt: 'timestamp'},
2017-05-10 11:04:06 +02:00
});
// optional more indices
UserSchema.index({timestamp: 1});
module.exports = mongoose.model('User', UserSchema);