achieve_expert.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  7. // 专家临时账号表
  8. // 使用手机号密码登录
  9. const achieve_expert = {
  10. expert_user_id: { type: ObjectId }, // 专家的用户id
  11. expert_name: { type: String }, // 专家姓名
  12. phone: { type: String }, // 电话
  13. password: { type: Secret, select: false },
  14. status: { type: String, default: '0' }, // 0=>使用中;-1=>禁用中
  15. remark: { type: String, maxLength: 200 },
  16. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  17. };
  18. const schema = new Schema(achieve_expert, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ expert_user_id: 1 });
  21. schema.index({ expert_name: 1 });
  22. schema.index({ phone: 1 });
  23. schema.index({ apply_id: 1 });
  24. schema.index({ status: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Achieve_expert', schema, 'achieve_expert');
  30. };