agentMech.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
  7. // 代理机构表
  8. const agent_mech = {
  9. pid: { type: ObjectId }, // 管理员id
  10. pid_name: { type: String }, // 管理员名称
  11. mech_name: { type: String }, // 机构名称
  12. name: { type: String }, // 姓名
  13. phone: { type: String }, // 手机号
  14. password: { type: Secret, select: false }, // 密码
  15. role: { type: String, default: '4' }, // 角色
  16. remark: { type: String },
  17. };
  18. const schema = new Schema(agent_mech, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ pid: 1 });
  21. schema.index({ pid_name: 1 });
  22. schema.index({ mech_name: 1 });
  23. schema.index({ name: 1 });
  24. schema.index({ phone: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('AgentMech', schema, 'agentMech');
  30. };