12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 学员与教练关系表
- const relationStudentCoach = {
- student_id: { type: String, required: true, zh: '学生id', ref: 'Student', getProp: [ 'name' ] }, //
- coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'icon', 'name', 'phone', 'age', 'gender', 'level', 'honor' ] }, //
- doc: { type: Object, required: false, zh: '档案' }, //
- config: { type: Object, required: false, zh: '设置' }, //
- };
- const schema = new Schema(relationStudentCoach, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ student_id: 1 });
- schema.index({ coach_id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('RelationStudentCoach', schema, 'relationStudentCoach');
- };
|