room.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 房间广告位
  5. const AdvertInfo = {
  6. title: { type: String, required: false }, // 广告标题
  7. imgdir: { type: String, required: false }, // 图片地址
  8. imgurl: { type: String, required: false }, // 图片链接地址
  9. };
  10. const RoomSchema = {
  11. name: { type: String, required: false, maxLength: 200 }, // 房间名称
  12. title: { type: String, required: false, maxLength: 200 }, // 标题
  13. type: { type: String, required: false, maxLength: 64 }, // 类型0、直播1、会议
  14. filedir: { type: String, required: false, maxLength: 200 }, // 封面图片
  15. url: { type: String, required: false, maxLength: 200 }, // 房间地址
  16. content: { type: String, required: false }, // 直播简介
  17. anchorid: { type: String, required: false, maxLength: 200 }, // 主播id
  18. username: { type: String, required: false, maxLength: 200 }, // 主播名称
  19. starttime: { type: String, required: false }, // 开始时间
  20. endtime: { type: String, required: false }, // 结束时间
  21. status: { type: String, required: false, maxLength: 64, default: '0' }, // 状态0、开启1、关闭
  22. isadvert: { type: Boolean, required: false, default: false }, // 是否有广告位0、开启1、关闭
  23. adverts: { type: [ AdvertInfo ], required: false, select: true }, // 广告位
  24. };
  25. const schema = new Schema(RoomSchema, { toJSON: { virtuals: true } });
  26. schema.index({ id: 1 });
  27. schema.plugin(metaPlugin);
  28. module.exports = app => {
  29. const { mongoose } = app;
  30. return mongoose.model('Room', schema, 'room');
  31. };