group.js 800 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 GroupSchema = {
  6. name: { type: String, required: true, maxLength: 500 }, // 名称
  7. termid: { type: String, required: false, maxLength: 500 }, // 期id
  8. batchid: { type: String, required: false, maxLength: 500 }, // 批次id
  9. classid: { type: String, required: false, maxLength: 500 }, // 班级id
  10. studentid: [ String ], // 学生id
  11. score: { type: String, required: false, maxLength: 500 }, // 分数
  12. };
  13. const schema = new Schema(GroupSchema, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('Group', schema, 'group');
  19. };