business.js 1.3 KB

12345678910111213141516171819202122232425262728293031
  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 BusinessSchema = {
  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. mobile: { type: String, required: true, maxLength: 500 }, // 创建时间
  15. address: { type: String, required: true, maxLength: 500 }, // 创建时间
  16. weixin: { type: String, required: true, maxLength: 500 }, // 创建时间
  17. gzh: { type: String, required: true, maxLength: 500 }, // 创建时间
  18. weibo: { type: String, required: true, maxLength: 500 }, // 创建时间
  19. beian: { type: String, required: true, maxLength: 500 }, // 创建时间
  20. };
  21. const schema = new Schema(BusinessSchema, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Business', schema, 'business');
  27. };