relationStudentCoach.js 1.1 KB

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 学员与教练关系表
  5. const relationStudentCoach = {
  6. student_id: { type: String, required: true, zh: '学生id', ref: 'Student', getProp: [ 'name' ] }, //
  7. coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'icon', 'name', 'phone', 'age', 'gender', 'level', 'honor' ] }, //
  8. school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: [ 'name', 'phone' ] }, //
  9. doc: { type: Object, required: false, zh: '档案' }, //
  10. config: { type: Object, required: false, zh: '设置' }, // 打折方式 discount_type:fixed 固定;subtract 减; discount折 ;number
  11. };
  12. const schema = new Schema(relationStudentCoach, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.index({ student_id: 1 });
  16. schema.index({ coach_id: 1 });
  17. schema.index({ school_id: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('RelationStudentCoach', schema, 'relationStudentCoach');
  22. };