1234567891011121314151617181920212223242526 |
- '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 coachInBill = {
- lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
- type: { type: String, required: false, zh: '类型' }, // 0:公开课收入;1私教课收入
- school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
- coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
- is_settle: { type: String, required: false, default: '0', zh: '是否结算' }, // 0:未结算;1已结算
- };
- const schema = new Schema(coachInBill, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ school_id: 1 });
- schema.index({ coach_id: 1 });
- schema.index({ is_settle: 1 });
- schema.plugin(metaPlugin);
- schema.plugin(moneyPlugin({ zh: '金额' }));
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('CoachInBill', schema, 'coachInBill');
- };
|