groupchat.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 群聊信息表
  5. const GroupchatSchema = {
  6. doctorid: { type: String, required: true, maxLength: 500 }, // 医生id
  7. doctorname: { type: String, required: true, maxLength: 500 }, // 医生名称
  8. groupid: { type: String, required: true, maxLength: 50 }, // 群id
  9. groupname: { type: String, required: true, maxLength: 50 }, // 群名称
  10. type: { type: String, required: false, maxLength: 200 }, // 类别0、医生1、患者
  11. sendid: { type: String, required: false, maxLength: 200 }, // 发送人ID
  12. sendname: { type: String, required: false, maxLength: 200 }, // 发送人姓名
  13. sendtime: { type: String, required: false }, // 发送时间
  14. contenttype: { type: String, required: false, maxLength: 20 }, // 类别0、图片1、音频、2、视频、3、文字
  15. content: { type: String, required: false }, // 内容
  16. audiotime: { type: String, required: false, maxLength: 100 }, // 语音时长
  17. };
  18. const schema = new Schema(GroupchatSchema, { toJSON: { virtuals: true } });
  19. schema.index({ groupid: 1 });
  20. schema.index({ sendid: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Groupchat', schema, 'group_chat');
  26. };