lesson.js 1.2 KB

123456789101112131415161718192021222324252627282930
  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. teaname: { type: String, required: false, maxLength: 500 }, // 教师名称
  7. teaid: { type: String, required: false, maxLength: 500 }, // 教师id
  8. subname: { type: String, required: false, maxLength: 200 }, // 科目名称
  9. subid: { type: String, required: false, maxLength: 200 }, // 科目id
  10. date: { type: String, required: false, maxLength: 500 }, // 日期
  11. day: { type: String, required: false, maxLength: 500 }, // 课程天数,半天或一天
  12. });
  13. // 课程表
  14. const LessonSchema = {
  15. classid: { type: String, required: true, maxLength: 500 }, // 班级id
  16. termid: { type: String, required: true, maxLength: 500 }, // 期id
  17. batchid: { type: String, required: true, maxLength: 500 }, // 批次id
  18. lessons: { type: [ lessonInfo ], select: true }, // 课程信息
  19. };
  20. const schema = new Schema(LessonSchema, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Lesson', schema, 'lesson');
  26. };