relationCoachSchool.js 1.0 KB

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
  5. // 教练与学校的关系表
  6. const relationCoachSchool = {
  7. coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'name', 'phone', 'level', 'icon' ] }, //
  8. school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: [ 'name', 'phone' ] }, //
  9. doc: { type: Object, required: false, zh: '教练档案' }, //
  10. };
  11. const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true, getters: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.index({ coach_id: 1 });
  15. schema.index({ school_id: 1 });
  16. schema.plugin(metaPlugin);
  17. schema.plugin(moneyPlugin({ zh: '工资' }));
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');
  21. };