mechanism.js 1.3 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. 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. status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
  17. isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
  18. remark: { type: String },
  19. create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
  20. };
  21. const schema = new Schema(mechanism, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.index({ name: 1 });
  24. schema.index({ industry: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Mechanism', schema, 'mechanism');
  30. };