'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 学籍信息信息库 const SchemaDefine = { schid: { type: String, required: true, maxLength: 64 }, // 学校ID,等同于yxdm year: { type: String, required: true, maxLength: 64 }, // 毕业年份 xh: { type: String, required: true, maxLength: 64 }, // 学号 xm: { type: String, required: true, maxLength: 64 }, // 姓名 sfzh: { type: String, required: true, maxLength: 64 }, // 身份证号 xb: { type: String, required: true, maxLength: 64 }, // 性别 mz: String, // 民族 zzmm: String, // 政治面貌 yxdm: { type: String, required: true, maxLength: 64 }, // 院校代码 yxmc: { type: String, required: true, maxLength: 64 }, // 院校名称 zydm: String, // 专业代码 zymc: { type: String, required: true, maxLength: 64 }, // 专业名称 xldm: String, // 学历代码 xl: { type: String, required: true, maxLength: 64 }, // 学历 syszddm: String, // 生源所在地代码 syszd: String, // 生源所在地 szyx: String, // 所在院系 szbj: String, // 所在班级 }; const schema = new Schema(SchemaDefine, { toJSON: { virtuals: true } }); schema.index({ year: 1 }); schema.index({ year: 1, schid: 1 }); schema.index({ schid: 1, xh: 1 }, { unique: true, sparse: true }); // 同一学校学号必须唯一 schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Enrollment', schema, 'stud_enrollment'); };