road_show.js 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 项目路演表
  8. const road_show = {
  9. user_id: { type: ObjectId },
  10. dock_id: { type: ObjectId }, // 展会id
  11. title: { type: String, required: false, maxLength: 500 }, // 标题
  12. brief: { type: String, maxLength: 100 }, // 简介
  13. origin: { type: String, required: false, maxLength: 500, default: '网站管理员' }, // 来源
  14. publish_time: { type: String, required: false, maxLength: 500 }, // 发布时间
  15. content: { type: String, required: false }, // 正文
  16. picture: { type: String, required: false }, // 图片路径
  17. filepath: { type: String, required: false }, // 文件路径
  18. remark: { type: String, maxLength: 200 },
  19. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  20. };
  21. const schema = new Schema(road_show, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.index({ dock_id: 1 });
  24. schema.index({ title: 1 });
  25. schema.index({ origin: 1 });
  26. schema.index({ publish_time: 1 });
  27. schema.index({ 'meta.createdAt': 1 });
  28. schema.plugin(metaPlugin);
  29. module.exports = app => {
  30. const { mongoose } = app;
  31. return mongoose.model('Road_show', schema, 'road_show');
  32. };