123456789101112131415161718192021222324252627282930 |
- '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 lesson = {
- school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
- title: { type: String, required: false, zh: '课程标题' }, //
- time_start: { type: String, required: false, zh: '开始上课时间' }, //
- time_end: { type: String, required: false, zh: '结束时间' }, //
- limit: { type: Number, zh: '人数上限' },
- refund_hour: { type: String, zh: '退款期限' },
- type: { type: String, required: false, zh: '课程类型', default: '0' }, // 0:公开课;1私教课
- status: { type: String, required: false, zh: '状态', default: '0' }, // 0-准备中;1-报名中;2-报名结束;3-已开课;4-已结课;-1-停课
- brief: { type: String, required: false, zh: '简介' }, //
- };
- const schema = new Schema(lesson, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ school_id: 1 });
- schema.index({ time_start: 1 });
- schema.index({ time_end: 1 });
- schema.plugin(metaPlugin);
- schema.plugin(moneyPlugin({ zh: '工资' }));
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Lesson', schema, 'lesson');
- };
|