attendance.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 考勤信息表
  5. const attendInfo = new Schema({
  6. date: { type: String, required: false, maxLength: 200 }, // 日期
  7. time: { type: String, required: false, maxLength: 200 }, // 时间
  8. status: { type: String, required: false, maxLength: 200 }, // 是否签到,0-未签到,1-签到,2-迟到
  9. });
  10. // 考勤表
  11. const AttendanceSchema = {
  12. termid: { type: String, required: false, maxLength: 200 }, // 期id
  13. batchid: { type: String, required: false, maxLength: 200 }, // 批次id
  14. classid: { type: String, required: false, maxLength: 200 }, // 班级id
  15. studentid: { type: String, required: false, maxLength: 200 }, // 学生id
  16. attend: { type: [ attendInfo ], select: true }, // 考勤信息
  17. };
  18. const schema = new Schema(AttendanceSchema, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Attendance', schema, 'attendance');
  24. };