match.js 914 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 比赛
  7. const match = {
  8. name: { type: String }, // 比赛名称
  9. match_time: { type: String }, // 时间
  10. single_time: { type: String }, // 单场时间
  11. address: { type: String }, // 地点
  12. format: { type: Array }, // 赛制
  13. match_team: { type: Array }, // 比赛队伍
  14. status: { type: String, default: '0' }, // 状态
  15. remark: { type: String },
  16. };
  17. const schema = new Schema(match, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.index({ single_time: 1 });
  20. schema.index({ status: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Match', schema, 'match');
  26. };