mechanism.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  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 mechanism = {
  9. name: { type: String }, // 机构名
  10. contacts: { type: String }, // 联系人
  11. phone: { type: String }, // 联系电话
  12. passwd: { type: Secret, select: false }, // 密码
  13. email: { type: String }, // 电子邮箱
  14. address: { type: String }, // 联系地址
  15. industry: { type: String }, // 所属行业
  16. // 21-05-07添加区字段
  17. juris: { type: String }, // 辖区
  18. status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
  19. isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
  20. remark: { type: String },
  21. create_time: { type: String },
  22. };
  23. const schema = new Schema(mechanism, { toJSON: { virtuals: true } });
  24. schema.index({ id: 1 });
  25. schema.index({ name: 1 });
  26. schema.index({ industry: 1 });
  27. schema.index({ 'meta.createdAt': 1 });
  28. schema.plugin(metaPlugin);
  29. module.exports = app => {
  30. const { mongoose } = app;
  31. return mongoose.model('Mechanism', schema, 'mechanism');
  32. };