subject.js 662 B

1234567891011121314151617181920
  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. };
  10. const schema = new Schema(SubjectSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.plugin(metaPlugin);
  13. module.exports = app => {
  14. const { mongoose } = app;
  15. return mongoose.model('Subject', schema, 'subject');
  16. };