company.js 558 B

1234567891011121314151617
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 企业信息
  5. const CompanySchema = {
  6. company: { type: String, required: true, maxLength: 200 }, // 名称
  7. mobile: { type: String, required: false, maxLength: 500 }, // 电话
  8. };
  9. const schema = new Schema(CompanySchema, { toJSON: { virtuals: true } });
  10. schema.index({ id: 1 });
  11. schema.plugin(metaPlugin);
  12. module.exports = app => {
  13. const { mongoose } = app;
  14. return mongoose.model('Company', schema, 'company');
  15. };