channel.js 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  5. // 产品图片表
  6. const videos = new Schema({
  7. name: { type: String, required: true, maxLength: 200 }, // 视频标题
  8. start_time: { type: String, required: true, maxLength: 200 }, // 开始时间
  9. end_time: { type: String, required: true, maxLength: 200 }, // 结束时间
  10. url: { type: String, required: true, maxLength: 500 }, // 视频路径
  11. });
  12. const Channel = {
  13. user_id: { type: String, required: false, maxLength: 200 }, // 创建人id
  14. title: { type: String, required: false, maxLength: 200 }, // 标题
  15. province: { type: String, required: false }, // 省
  16. place: { type: String, required: false }, // 市
  17. orgin: { type: String, required: false, maxLength: 200 }, // 来源
  18. sponsor: { type: String, required: false, maxLength: 200 }, // 主办方
  19. organizer: { type: String, required: false, maxLength: 200 }, // 承办方
  20. desc: { type: String, maxLength: 1000 }, // 简介
  21. create_time: { type: String, required: false, maxLength: 200 }, // 创建时间
  22. image_path: { type: String, required: false }, // 图片路径
  23. videodata: { type: [ videos ], default: [] }, // vip用户
  24. };
  25. const schema = new Schema(Channel, { toJSON: { virtuals: true } });
  26. schema.index({ id: 1 });
  27. schema.plugin(metaPlugin);
  28. module.exports = app => {
  29. const { mongoose } = app;
  30. return mongoose.model('channel', schema, 'channel');
  31. };