hotspot.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 类型
  5. const typeInfo = new Schema({
  6. 0: { type: String, required: false, maxLength: 500 }, // 公司新闻
  7. 1: { type: String, required: false, maxLength: 500 }, // 行业新闻
  8. 2: { type: String, required: false, maxLength: 500 }, // 展会资讯
  9. });
  10. // 热点资讯表
  11. const hotspot = {
  12. name: { type: String, required: true, maxLength: 200 }, // 名称
  13. filepath: { type: String, required: false, maxLength: 200 }, // 图片路径
  14. create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
  15. content: { type: String, required: false, maxLength: 500 }, // 内容
  16. brief: { type: String, required: false, maxLength: 500 }, // 简介
  17. type: { type: [ typeInfo ], select: true }, // 回答详情
  18. };
  19. const schema = new Schema(hotspot, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = (app) => {
  23. const { mongoose } = app;
  24. return mongoose.model('Hotspot', schema, 'hotspot');
  25. };