relationCoachSchool.js 868 B

123456789101112131415161718192021
  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' ] }, //
  7. school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: [ 'name', 'phone' ] }, //
  8. doc: { type: Object, required: false, zh: '教练档案' }, //
  9. };
  10. const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ 'meta.createdAt': 1 });
  13. schema.index({ coach_id: 1 });
  14. schema.index({ school_id: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');
  19. };