class.js 862 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 班级表
  5. const ClassSchema = {
  6. name: { type: String, required: true, maxLength: 500 }, // 班级名称
  7. number: { type: String, required: false, maxLength: 200 }, // 人数
  8. batch: { type: String, required: false, maxLength: 200 }, // 批次
  9. term: { type: String, required: false, maxLength: 200 }, // 期
  10. headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id
  11. type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
  12. };
  13. const schema = new Schema(ClassSchema, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('Class', schema, 'class');
  19. };