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

45 lines
788 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 AppUserSchema = new Schema({
username: {
type: String,
required: true,
unique: true
},
password: {
type: String,
required: true
},
2017-06-08 19:46:36 +02:00
squad: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Squad',
default: null
},
2017-05-10 11:04:06 +02:00
permission: {
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
min: 0,
2017-06-08 13:14:53 +02:00
max: 4,
2017-05-10 11:04:06 +02:00
default: 0
2017-06-08 16:03:20 +02:00
},
secret: {
type: String,
required: true
},
activated: {
type: Boolean,
default: false
2017-05-10 11:04:06 +02:00
}
}, {
collection: 'app_user',
timestamps: {createdAt: 'timestamp'}
});
// optional more indices
AppUserSchema.index({timestamp: 1});
module.exports = mongoose.model('AppUser', AppUserSchema);