lesson.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 课程表
  5. const lesson = {
  6. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  7. title: { type: String, required: false, zh: '课程标题' }, //
  8. time_start: { type: String, required: false, zh: '开始上课时间' }, //
  9. time_end: { type: String, required: false, zh: '结束时间' }, //
  10. money: { type: Number, zh: '金额' },
  11. limit: { type: Number, zh: '人数上限' },
  12. refund_hour: { type: String, zh: '退款期限' },
  13. type: { type: String, required: false, zh: '课程类型', default: '0' }, // 0:公开课;1私教课
  14. status: { type: String, required: false, zh: '状态', default: '0' }, // 0-准备中;1-报名中;2-报名结束;3-已开课;4-已结课;-1-停课
  15. brief: { type: String, required: false, zh: '简介' }, //
  16. };
  17. const schema = new Schema(lesson, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.index({ 'meta.createdAt': 1 });
  20. schema.index({ school_id: 1 });
  21. schema.index({ time_start: 1 });
  22. schema.index({ time_end: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Lesson', schema, 'lesson');
  27. };