'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 患者入驻医生信息 const PatientdocsSchema = { patientid: { type: String, required: true, maxLength: 64 }, // 患者ID patientname: { type: String, required: true, maxLength: 128 }, // 患者名称 doctorid: { type: String, required: true, maxLength: 64 }, // 医生ID doctorname: { type: String, required: false, maxLength: 128 }, // 医生名称 }; const schema = new Schema(PatientdocsSchema, { toJSON: { virtuals: true } }); schema.index({ patientid: 1 }); schema.index({ doctorid: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('PatientDoctor', schema, 'patient_doctor'); };