'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-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: '档案' }, // money: { type: Number, zh: '余额' }, }; const schema = new Schema(relationStudentSchool, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ student_id: 1 }); schema.index({ school_id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('RelationStudentSchool', schema, 'relationStudentSchool'); };