|
@@ -0,0 +1,53 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
+
|
|
|
+
|
|
|
+const match_small_group_schedule = {
|
|
|
+ match_id: { type: String, required: true, zh: '赛事id', ref: 'Match', getProp: [ 'name' ] },
|
|
|
+ group_id: { type: String, required: true, zh: '组别id', ref: 'Group', getProp: [ 'name' ] },
|
|
|
+ project_id: { type: String, required: true, zh: '项目id', ref: 'Project', getProp: [ 'name' ] },
|
|
|
+ team_id: { type: String, required: true, zh: '小组id', ref: 'MatchTeamGroup', getProp: [ 'name' ] },
|
|
|
+ address_id: { type: String, required: true, zh: '场地id', ref: 'Address', getProp: [ 'name' ] },
|
|
|
+ referee_id: { type: String, required: true, zh: '裁判id', ref: 'User', getProp: [ 'name' ] },
|
|
|
+ match_time: { type: String, required: true, zh: '比赛时间' },
|
|
|
+ player_type: { type: String, required: true, zh: '选手类型' },
|
|
|
+ player_one: { type: String, required: true, zh: '选手一', refPath: 'player_type' },
|
|
|
+ player_one_score: { type: String, required: false, zh: '选手一比分' },
|
|
|
+ player_two: { type: String, required: true, zh: '选手二', refPath: 'player_type' },
|
|
|
+ player_two_score: { type: String, required: false, zh: '选手二比分' },
|
|
|
+ is_change: { type: String, required: false, default: '0', zh: '是否交换' },
|
|
|
+ status: { type: String, required: false, default: '0', zh: '赛程状态' },
|
|
|
+ winner: { type: String, required: false, zh: '胜者' },
|
|
|
+};
|
|
|
+const schema = new Schema(match_small_group_schedule, { 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({ team_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('Msgs', schema, 'msgs');
|
|
|
+ } else {
|
|
|
+ const { mongoose } = app;
|
|
|
+ model = mongoose.model('Msgs', schema, 'msgs');
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+};
|