lesson.js 1.0 KB

12345678910111213141516171819202122232425262728
  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. date: { type: String, required: false, maxLength: 500 }, // 日期
  9. day: { type: String, required: false, maxLength: 500 }, // 课程天数,半天或一天
  10. });
  11. // 课程表
  12. const LessonSchema = {
  13. class: { type: String, required: true, maxLength: 500 }, // 班级
  14. term: { type: String, required: true, maxLength: 500 }, // 期
  15. batch: { type: String, required: true, maxLength: 500 }, // 批次
  16. lessons: { type: [ lessonInfo ], select: true }, // 课程信息
  17. };
  18. const schema = new Schema(LessonSchema, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Lesson', schema, 'lesson');
  24. };