'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose-free/lib/model/schema'); // 系统管理员表 const admin = { name: { type: String, default: '系统管理员' }, // 显示名称 account: { type: String }, // 账号 password: { type: Secret, select: false }, // 密码 remark: { type: String }, }; const schema = new Schema(admin, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Admin', schema, 'admin'); };