subject.js 778 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 科目表
  5. const SubjectSchema = {
  6. code: { type: String, required: false, maxLength: 200 }, // 科目代码
  7. name: { type: String, required: false, maxLength: 500 }, // 科目名称
  8. type: { type: String, required: false, maxLength: 500 }, // 类型,0-普通班,1-特殊班
  9. need_teacher: { type: String, required: false, maxLength: 100, default: '0' }, // 类型,0-需要,1-不需要
  10. };
  11. const schema = new Schema(SubjectSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Subject', schema, 'subject');
  17. };