'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin'); // 课程表-教练 const lessonCoach = { lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, // school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, // coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, // is_sign: { type: String, required: false, default: '0', zh: '签到' }, // 0:未到;1:已签到 }; const schema = new Schema(lessonCoach, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ lesson_id: 1 }); schema.index({ school_id: 1 }); schema.index({ coach_id: 1 }); schema.index({ is_sign: 1 }); schema.plugin(metaPlugin); schema.plugin(moneyPlugin({ zh: '课时费' })); module.exports = app => { const { mongoose } = app; return mongoose.model('LessonCoach', schema, 'lessonCoach'); };