lesson.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 课程信息表
  5. const lessonInfo = new Schema({
  6. name: { type: String, required: false, maxLength: 500 }, // 名称
  7. teacherid: { type: String, required: false, maxLength: 500 }, // 教师id
  8. subid: { type: String, required: false, maxLength: 200 }, // 科目id
  9. date: { type: String, required: false, maxLength: 500 }, // 日期
  10. day: { type: String, required: false, maxLength: 500 }, // 课程天数,半天或一天
  11. });
  12. // 课程表
  13. const LessonSchema = {
  14. class: { type: String, required: true, maxLength: 500 }, // 班级
  15. term: { type: String, required: true, maxLength: 500 }, // 期
  16. batch: { type: String, required: true, maxLength: 500 }, // 批次
  17. lessons: { type: [ lessonInfo ], select: true }, // 课程信息
  18. };
  19. const schema = new Schema(LessonSchema, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Lesson', schema, 'lesson');
  25. };