company.js 839 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 图片路径
  5. const image = new Schema({
  6. url: { type: String, required: false, maxLength: 500 }, // 图片路径
  7. });
  8. // 企业信息表
  9. const company = {
  10. company: { type: String, required: true, maxLength: 200 }, // 企业名称
  11. engCompany: { type: String, required: true, maxLength: 200 }, // 英文名称
  12. brief: { type: String, required: true, maxLength: 200 }, // 简介
  13. imagearray: { type: [ image ], select: true, maxLength: 500 }, // 图片(数组)
  14. };
  15. const schema = new Schema(company, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('Company', schema, 'company');
  21. };