channel.js 1.4 KB

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