'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 = { account: { type: String, required: false, zh: '账号' }, // password: { type: Secret, required: false, select: false, zh: '密码' }, // role: { type: String, zh: '角色', ref: 'Dev.Role' }, shop: { type: String, zh: '店铺', ref: 'Shop.Shop' }, name: { type: String, required: false, zh: '名称' }, // }; const schema = new Schema(admin, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ account: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Admin', schema, 'admin'); };