'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 淘汰赛赛程 const eliminate = { match_id: { type: String, required: false, zh: '赛事i', ref: 'Race.Match' }, // group_id: { type: String, required: false, zh: '组别id', ref: 'Race.MatchGroup' }, // project_id: { type: String, required: false, zh: '项目id', ref: 'Race.MatchProject' }, // address_id: { type: String, required: false, zh: '场地id', ref: 'Race.MatchAddress' }, // referee_id: { type: String, required: false, zh: '裁判id', ref: 'Race.User' }, // match_time: { type: String, required: false, zh: '比赛时间' }, // player_type: { type: String, required: false, zh: '选手类型' }, // 0:单打,user;1:双打,teamApply player_one: { type: String, required: false, zh: '选手一' }, // player_one_score: { type: Number, required: false, zh: '选手一比分' }, // player_one_node: { type: String, required: false, zh: '选手一节点' }, // player_two: { type: String, required: false, zh: '选手二' }, // player_two_score: { type: Number, required: false, zh: '选手二比分' }, // player_two_node: { type: String, required: false, zh: '选手二节点' }, // is_change: { type: String, required: false, default: '0', zh: '是否交换' }, // status: { type: String, required: false, default: '0', zh: '赛程状态' }, // 0:待开始,1:已开始,2:已结束 winner: { type: String, required: false, zh: '胜者' }, // }; const schema = new Schema(eliminate, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ match_id: 1 }); schema.index({ group_id: 1 }); schema.index({ project_id: 1 }); schema.index({ address_id: 1 }); schema.index({ referee_id: 1 }); schema.index({ match_time: 1 }); schema.index({ player_type: 1 }); schema.index({ player_one: 1 }); schema.index({ player_two: 1 }); schema.index({ is_change: 1 }); schema.index({ status: 1 }); schema.plugin(metaPlugin); const source = 'race'; module.exports = app => { const is_multiple = app.mongooseDB.clients; let model; if (is_multiple) { const conn = app.mongooseDB.get(source); model = conn.model('Eliminate', schema, 'eliminate'); } else { const { mongoose } = app; model = mongoose.model('Eliminate', schema, 'eliminate'); } return model; };