relationCoachSchool.js 913 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 教练与学校的关系表
  5. const relationCoachSchool = {
  6. coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: ['name', 'phone', 'level', 'icon'] }, //
  7. school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: ['name', 'phone'] }, //
  8. doc: { type: Object, required: false, zh: '教练档案' }, //
  9. money: { type: Number, zh: '工资' },
  10. };
  11. const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.index({ coach_id: 1 });
  15. schema.index({ school_id: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');
  20. };