'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const termInfo = new Schema({ termnum: { type: String, required: false, maxLength: 200 }, // 期数 termid: { type: String, required: false, maxLength: 200 }, // 期id number: { type: String, required: false, maxLength: 200 }, // 人数 type: { type: String, required: false, maxLength: 200 }, // 类别 }); // 培训计划学校上报时间表 const SchtimeSchema = { schid: { type: String, required: true, maxLength: 500 }, // 学校id year: { type: String, required: false, maxLength: 200 }, // 年份 planid: { type: String, requiredl: false, maxLength: 200 }, // 培训计划表id remark: { type: String, requiredl: false, maxLength: 500 }, // 备注 term: { type: [ termInfo ], select: true }, // 期 }; const schema = new Schema(SchtimeSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Schtime', schema, 'schtime'); };