relationStudentSchool.js 848 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 学员与学校关系表
  5. const relationStudentSchool = {
  6. student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name' ] }, //
  7. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  8. doc: { type: Object, required: false, zh: '档案' }, //
  9. };
  10. const schema = new Schema(relationStudentSchool, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ student_id: 1 });
  13. schema.index({ school_id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('RelationStudentSchool', schema, 'relationStudentSchool');
  19. };