|
@@ -0,0 +1,39 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
+
|
|
|
+
|
|
|
+const match_team_group = {
|
|
|
+ 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' ] },
|
|
|
+ name: { type: String, required: true, zh: '分组名称' },
|
|
|
+ person_type: { type: String, required: false, zh: '人员类型' },
|
|
|
+ person: { type: Array, required: false, zh: '组内人员', refPath: 'person_type' },
|
|
|
+ remark: { type: String, required: false, zh: '备注' },
|
|
|
+ rise: { type: String, required: true, zh: '取前几' },
|
|
|
+};
|
|
|
+const schema = new Schema(match_team_group, { 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({ name: 1 });
|
|
|
+schema.index({ rise: 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('MatchTeamGroup', schema, 'MatchTeamGroup');
|
|
|
+ } else {
|
|
|
+ const { mongoose } = app;
|
|
|
+ model = mongoose.model('MatchTeamGroup', schema, 'MatchTeamGroup');
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+};
|