train_live.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 video = new Schema({
  6. video_title: { type: String, maxLength: 500 }, // 标题
  7. video_date: { type: String, maxLength: 500 }, // 时间
  8. video_url: { type: String, maxLength: 500 }, // 视频路径
  9. });
  10. const user = new Schema({
  11. user_title: { type: String, maxLength: 500 }, // 用户名
  12. user_phone: { type: String, maxLength: 500 }, // 账号
  13. user_password: { type: String, maxLength: 500 }, // 密码
  14. });
  15. // 培训问诊表
  16. const trainlive = {
  17. room_id: { type: String, required: true, unique: true }, // 房间号
  18. password: { type: String }, // 密码
  19. title: { type: String }, // 标题
  20. province: { type: String }, // 省份
  21. place: { type: String }, // 市区
  22. sponsor: { type: String }, // 主办方
  23. brief: { type: String }, // 简介
  24. user: { type: String }, // 负责人
  25. phone: { type: String }, // 负责人手机号
  26. video_data: { type: [ video ] }, // 视频
  27. user_data: { type: [ user ], select: false }, // 参加用户
  28. start_date: { type: String }, // 开始时间
  29. type: { type: String, default: 'train' }, // 类型
  30. remark: { type: String, maxLength: 200 },
  31. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  32. };
  33. const schema = new Schema(trainlive, { toJSON: { virtuals: true } });
  34. schema.index({ id: 1 });
  35. schema.index({ room_id: 1 });
  36. schema.index({ title: 1 });
  37. schema.index({ province: 1 });
  38. schema.index({ city: 1 });
  39. schema.index({ user: 1 });
  40. schema.index({ phone: 1 });
  41. schema.index({ 'meta.createdAt': 1 });
  42. schema.plugin(metaPlugin);
  43. module.exports = app => {
  44. const { mongoose } = app;
  45. return mongoose.model('Train_live', schema, 'train_live');
  46. };