opt-cc/api/models/user.js

31 lines
579 B
JavaScript
Raw Normal View History

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),
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);