'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 临时上课申请 const tempLessonApply = { school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, // lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, // student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name' ] }, // coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, // result: { type: String, required: false, default: '0', zh: '审核结果' }, // 0:未审核;1:审核通过;-1审核失败 reason: { type: String, required: false, zh: '审核原因' }, // img_url: { type: Array, required: false, zh: '证据' }, // }; const schema = new Schema(tempLessonApply, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ school_id: 1 }); schema.index({ lesson_id: 1 }); schema.index({ student_id: 1 }); schema.index({ coach_id: 1 }); schema.index({ result: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('TempLessonApply', schema, 'tempLessonApply'); };