'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 课程表 const lesson = { school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, // coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, // title: { type: String, zh: '标题' }, class_hour: { type: Number, required: false, zh: '课时' }, // money: { type: Number, required: false, zh: '金额' }, // student: { type: Array, ref: 'Student', getProp: [ 'name' ], zh: '学员' }, type: { type: String, required: false, zh: '类型' }, // 0-公开课;1-私教课 }; const schema = new Schema(lesson, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ school_id: 1 }); schema.index({ title: 1 }); schema.index({ coach_id: 1 }); schema.index({ type: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Lesson', schema, 'lesson'); };