schedule.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-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 赛程信息
  7. const schedule = {
  8. match_id: { type: String }, // 比赛id
  9. match_name: { type: String }, // 比赛名称
  10. red_id: { type: String }, // 比赛红方id
  11. red_name: { type: String }, // 比赛红方名称
  12. red_logo: { type: Array }, // 比赛红方logo
  13. red_members: { type: Array }, // 比赛红方成员
  14. red_branch: { type: String }, // 比赛红方比分
  15. red_integral: { type: String }, // 比赛红方积分
  16. red_position: { type: String }, // 比赛流程图位置
  17. blue_id: { type: String }, // 比赛蓝方id
  18. blue_name: { type: String }, // 比赛蓝方名称
  19. blue_logo: { type: Array }, // 比赛蓝方logo
  20. blue_members: { type: Array }, // 比赛蓝方成员
  21. blue_branch: { type: String }, // 比赛蓝方比分
  22. blue_integral: { type: String }, // 比赛蓝方积分
  23. blue_position: { type: String }, // 比赛流程图位置
  24. match_time: { type: String }, // 比赛时间
  25. match_file: { type: Array }, // 比赛图片
  26. status: { type: String, default: "0" }, // 状态
  27. position: { type: String }, // 比赛场次轮数
  28. format: { type: Array }, // 赛制
  29. is_bye: { type: Boolean, default: false }, // 是否轮空, 轮空只有1个队伍
  30. remark: { type: String },
  31. };
  32. const schema = new Schema(schedule, { toJSON: { virtuals: true } });
  33. schema.index({ id: 1 });
  34. schema.index({ match_id: 1 });
  35. schema.index({ red_id: 1 });
  36. schema.index({ blue_id: 1 });
  37. schema.index({ match_time: 1 });
  38. schema.index({ status: 1 });
  39. schema.index({ 'meta.createdAt': 1 });
  40. schema.plugin(metaPlugin);
  41. module.exports = app => {
  42. const { mongoose } = app;
  43. return mongoose.model('Schedule', schema, 'schedule');
  44. };