school.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 SchoolSchema = {
  6. code: { type: String, required: false, maxLength: 200 }, // 学校代码
  7. name: { type: String, required: false, maxLength: 500 }, // 学校名称
  8. logourl: { type: String, required: false, maxLength: 500 }, // logo路径
  9. level: { type: String, required: false, maxLength: 500 }, // 高校层次
  10. address: { type: String, required: false, maxLength: 500 }, // 高校地址
  11. number: { type: String, required: false, maxLength: 500 }, // 人数
  12. };
  13. const schema = new Schema(SchoolSchema, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('School', schema, 'school');
  19. };