opt-cc/server/models/user.js

31 lines
588 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,
},
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);