'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 赛程信息 const schedule = { match_id: { type: String }, // 比赛id match_name: { type: String }, // 比赛名称 red_id: { type: String }, // 比赛红方id red_name: { type: String }, // 比赛红方名称 red_logo: { type: Array }, // 比赛红方logo red_members: { type: Array }, // 比赛红方成员 blue_id: { type: String }, // 比赛蓝方id blue_name: { type: String }, // 比赛蓝方名称 blue_logo: { type: Array }, // 比赛蓝方logo blue_members: { type: Array }, // 比赛蓝方成员 branch: { type: Object }, // 比分 integral: { type: Object }, // 积分 match_time: { type: String }, // 比赛时间 match_file: { type: Array }, // 比赛图片 status: { type: String, default: '0' }, // 状态 format: { type: Array }, // 赛制 is_bye: { type: Boolean, default: false }, // 是否轮空, 轮空只有1个队伍 remark: { type: String }, }; const schema = new Schema(schedule, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ match_id: 1 }); schema.index({ red_id: 1 }); schema.index({ blue_id: 1 }); schema.index({ match_time: 1 }); schema.index({ status: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Schedule', schema, 'schedule'); };