online.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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 { ObjectId } = require('mongoose').Types;
  6. // 在线表
  7. const online = {
  8. column_name: { type: String }, // 栏目名
  9. title: { type: String }, // 标题
  10. image: { type: Array }, // 封面
  11. organizers: { type: String }, // 举办方
  12. contacts: { type: String }, // 联系人
  13. phone: { type: String }, // 联系电话
  14. province: { type: String }, // 省
  15. city: { type: String }, // 市
  16. start_time: { type: String }, // 举办开始时间
  17. end_time: { type: String }, // 举办结束时间
  18. brief: { type: String }, // 信息简介
  19. video: { type: Array }, // 视频
  20. status: { type: String, default: '0' }, // 0:准备中;1:开始;2:结束
  21. remark: { type: String },
  22. create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
  23. };
  24. const schema = new Schema(online, { toJSON: { virtuals: true } });
  25. schema.index({ id: 1 });
  26. schema.index({ column_name: 1 });
  27. schema.index({ title: 1 });
  28. schema.index({ start_time: 1 });
  29. schema.index({ end_time: 1 });
  30. schema.index({ status: 1 });
  31. schema.index({ 'meta.createdAt': 1 });
  32. schema.plugin(metaPlugin);
  33. module.exports = app => {
  34. const { mongoose } = app;
  35. return mongoose.model('Online', schema, 'online');
  36. };