lessonCoach.js 1.1 KB

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