channel.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 科技频道表
  8. const channel = {
  9. room_id: { type: String }, // 房间id,服务生成,从2001开始
  10. password: { type: Secret }, // 密码,房间号
  11. title: { type: String }, // 标题
  12. origin: { type: String }, // 来源
  13. type: { type: String }, // 类别
  14. brief: { type: String }, // 简介
  15. create_time: { type: String }, // 更新时间
  16. status: { type: String, default: '0' }, // 0-准备中;1-开始;-1-结束
  17. role: { type: String, required: false, default: '7' }, // 角色
  18. remark: { type: String },
  19. };
  20. const schema = new Schema(channel, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.index({ room_id: 1 });
  23. schema.index({ title: 1 });
  24. schema.index({ type: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Channel', schema, 'channel');
  30. };