contacts.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  5. // 企业联系人信息表
  6. const ContactsSchema = {
  7. uid: { type: String, required: true, maxLength: 200 }, // 关联企业用户id
  8. name: { type: String, required: true, maxLength: 200 }, // 联系人姓名
  9. position: { type: String, required: true, maxLength: 200 }, // 职位
  10. gender: { type: String, required: true, maxLength: 200 }, // 性别
  11. email: { type: String, required: true, maxLength: 200 }, // 电子邮箱
  12. telephone: { type: String, required: true, maxLength: 200 }, // 固定电话
  13. phone: { type: String, required: true, maxLength: 200 }, // 常用手机
  14. contact_addr_city: { type: String, required: true, maxLength: 200 }, // 联系地址-市
  15. contact_addr_area: { type: String, required: true, maxLength: 200 }, // 联系地址-区
  16. detail_addr: { type: String, required: true, maxLength: 200 }, // 详细地址
  17. };
  18. const schema = new Schema(ContactsSchema, { toJSON: { virtuals: true } });
  19. schema.index({ uid: 1 });
  20. schema.index({ id: 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Contacts', schema, 'contacts');
  25. };