opt-cc/api/models/app-user.js

49 lines
848 B
JavaScript

"use strict";
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const AppUserSchema = new Schema({
username: {
type: String,
required: true,
unique: true
},
display_name: {
type: String,
required: true
},
password: {
type: String,
required: true
},
squad: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Squad',
default: null
},
permission: {
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
min: 0,
max: 4,
default: 0
},
secret: {
type: String,
required: true
},
activated: {
type: Boolean,
default: false
}
}, {
collection: 'app_user',
timestamps: {createdAt: 'timestamp'}
});
// optional more indices
AppUserSchema.index({timestamp: 1});
module.exports = mongoose.model('AppUser', AppUserSchema);