'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 学员与学校关系表 const relationStudentSchool = { student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name' ] }, // school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, // doc: { type: Object, required: false, 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'); };