patientdocs.js 835 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 患者入驻医生信息
  5. const PatientdocsSchema = {
  6. patientid: { type: String, required: true, maxLength: 64 }, // 患者ID
  7. patientname: { type: String, required: true, maxLength: 128 }, // 患者名称
  8. doctorid: { type: String, required: true, maxLength: 64 }, // 医生ID
  9. doctorname: { type: String, required: false, maxLength: 128 }, // 医生名称
  10. };
  11. const schema = new Schema(PatientdocsSchema, { toJSON: { virtuals: true } });
  12. schema.index({ patientid: 1 });
  13. schema.index({ doctorid: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('PatientDoctor', schema, 'patient_doctor');
  19. };