'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 课程信息表 const lessonInfo = new Schema({ teaname: { type: String, required: false, maxLength: 500 }, // 教师名称 teaid: { type: String, required: false, maxLength: 500 }, // 教师id subname: { type: String, required: false, maxLength: 200 }, // 科目名称 subid: { type: String, required: false, maxLength: 200 }, // 科目id date: { type: String, required: false, maxLength: 500 }, // 日期 time: { type: String, required: false, maxLength: 500 }, // 时间 day: { type: String, required: false, maxLength: 500 }, // 课程天数,半天或一天 reason: { type: String, required: false, maxLength: 500 }, // 原因 }); // 课程表 const LessonSchema = { classid: { type: String, required: true, maxLength: 500 }, // 班级id termid: { type: String, required: true, maxLength: 500 }, // 期id batchid: { type: String, required: true, maxLength: 500 }, // 批次id lessons: { type: [ lessonInfo ], required: false, select: true }, // 课程信息 }; const schema = new Schema(LessonSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Lesson', schema, 'lesson'); };