12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 教练与学校的关系表
- const relationCoachSchool = {
- coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'name', 'phone', 'level', 'icon' ] }, //
- school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: [ 'name', 'phone' ] }, //
- doc: { type: Object, required: false, zh: '教练档案' }, //
- salary: { type: Number, zh: '工资' },
- };
- const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ coach_id: 1 });
- schema.index({ school_id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');
- };
|