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

32 lines
582 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
},
permission: {
type: Number,
get: v => Math.round(v),
set: v => Math.round(v),
min: 0,
max: 3,
default: 0
}
}, {
collection: 'app_user',
timestamps: {createdAt: 'timestamp'}
});
// optional more indices
AppUserSchema.index({timestamp: 1});
module.exports = mongoose.model('AppUser', AppUserSchema);