'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; const { Secret } = require('naf-framework-mongoose-free/lib/model/schema'); // 代理机构表 const agent_mech = { pid: { type: ObjectId }, // 管理员id pid_name: { type: String }, // 管理员名称 mech_name: { type: String }, // 机构名称 name: { type: String }, // 姓名 phone: { type: String }, // 手机号 password: { type: Secret, select: false }, // 密码 role: { type: String, default: '4' }, // 角色 remark: { type: String }, }; const schema = new Schema(agent_mech, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ pid: 1 }); schema.index({ pid_name: 1 }); schema.index({ mech_name: 1 }); schema.index({ name: 1 }); schema.index({ phone: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('AgentMech', schema, 'agentMech'); };