school.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 学校
  5. const school = {
  6. name: { type: String, required: false, zh: '名称' }, //
  7. brief: { type: String, required: false, zh: '简介' }, //
  8. phone: { type: String, required: false, zh: '联系方式' }, //
  9. address: { type: String, required: false, zh: '训练地址' }, //
  10. coach_num: { type: Number, required: false, default: '0', zh: '教练人数' }, //
  11. student_num: { type: Number, required: false, default: '0', zh: '学员人数' }, //
  12. honor: { type: String, required: false, zh: '过往荣誉' }, //
  13. url: { type: String, required: false, zh: '网址' }, //
  14. yyzz: { type: Array, required: false, zh: '营业执照' }, //
  15. img_url: { type: Array, required: false, zh: '图片' }, //
  16. user_id: { type: String, required: false, zh: '用户表信息', ref: 'User', getProp: [ 'name' ] }, //
  17. };
  18. const schema = new Schema(school, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ 'meta.createdAt': 1 });
  21. schema.index({ name: 1 });
  22. schema.index({ user_id: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('School', schema, 'school');
  27. };