123456789101112131415161718192021222324252627282930313233343536373839 |
- '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: 'Race.Match', getProp: [ 'name' ] }, // 比赛信息中的名称
- group_id: { type: String, required: true, zh: '组别id', ref: 'Race.MatchGroup', getProp: [ 'name' ] }, // 赛事组别中的名称
- project_id: { type: String, required: true, zh: '项目id', ref: 'Race.MatchProject', getProp: [ 'name' ] }, // 组内项目中的名称
- name: { type: String, required: true, zh: '分组名称' }, //
- person_type: { type: String, required: false, zh: '人员类型' }, // 单打:user;双打:teamApply
- 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;
- };
|