relationCoachSchool.js 971 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const { Decimal128 } = require('mongoose').Types;
  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. money: { type: Decimal128, zh: '工资' },
  11. };
  12. const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.index({ coach_id: 1 });
  16. schema.index({ school_id: 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');
  21. };