lessonCoach.js 935 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 课程表-教练
  5. const lessonCoach = {
  6. lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
  7. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  8. coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
  9. money: { type: Number, required: false, zh: '课时费' }, //
  10. };
  11. const schema = new Schema(lessonCoach, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.index({ lesson_id: 1 });
  15. schema.index({ school_id: 1 });
  16. schema.index({ coach_id: 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('LessonCoach', schema, 'lessonCoach');
  21. };