'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 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' ] }, // img_url: { type: Array, required: false, zh: '证据' }, // pay_id: { type: String, required: false, zh: '支付id', ref: 'PayOrder' }, // }; const schema = new Schema(tempLessonApply, { toJSON: { getters: true, 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.index({ pay_id: 1 }); schema.plugin(metaPlugin); schema.plugin(moneyPlugin({ zh: '金额' })); module.exports = app => { const { mongoose } = app; return mongoose.model('TempLessonApply', schema, 'tempLessonApply'); };