room.js 799 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 群聊信息表
  5. const RoomSchema = {
  6. patientid: { type: String, required: false, maxLength: 200 }, // 患者ID
  7. patientname: { type: String, required: false, maxLength: 200 }, // 患者姓名
  8. doctorid: { type: String, required: false, maxLength: 200 }, // 医生ID
  9. doctorname: { type: String, required: false, maxLength: 200 }, // 医生姓名
  10. };
  11. const schema = new Schema(RoomSchema, { 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('Room', schema, 'room');
  19. };