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