12345678910111213141516171819202122232425262728 |
- '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 doc = {
- is_past: { type: String, default: '0' }, // 往期学员: 0-当期;1-往期
- term: { type: String }, // 学期
- };
- // 学员与学校关系表
- const relationStudentSchool = {
- student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name', 'icon', 'level', 'phone' ] }, //
- school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'img_url', 'name', 'phone', 'coach_num', 'student_num', 'address', 'brief' ] }, //
- doc: { type: Object, required: false, zh: '档案' }, //
- };
- const schema = new Schema(relationStudentSchool, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ student_id: 1 });
- schema.index({ school_id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- schema.plugin(moneyPlugin({ zh: '余额' }));
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('RelationStudentSchool', schema, 'relationStudentSchool');
- };
|