1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 课程表-私教课
- const lessonPrivate = {
- school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
- title: { type: String, required: false, zh: '课程标题' }, //
- coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
- money: { type: Number, required: false, zh: '金额' }, //
- limit: { type: Number, required: false, zh: '人数上限' }, //
- student: { type: Array, required: false, zh: '上课学员', ref: 'Student', getProp: [ 'name' ] }, // 存学员id
- time_start: { type: String, required: false, zh: '开始上课时间' }, //
- time_end: { type: String, required: false, zh: '结束时间' }, //
- status: { type: String, required: false, default: '0', zh: '状态' }, // 0-准备中;1-报名中;2-报名结束;3-已开课;4-已结课;-1-停课
- brief: { type: String, required: false, zh: '简介' }, //
- };
- const schema = new Schema(lessonPrivate, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ school_id: 1 });
- schema.index({ coach_id: 1 });
- schema.index({ student: 1 });
- schema.index({ time_start: 1 });
- schema.index({ time_end: 1 });
- schema.index({ status: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('LessonPrivate', schema, 'lessonPrivate');
- };
|