const mongoose = require('mongoose') const chatRoomMessageSchema = new mongoose.Schema({ roomId: { type: mongoose.Schema.Types.ObjectId, ref: 'ChatRoom', required: true, index: true }, senderId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, index: true }, content: { type: String, trim: true }, file: { type: String }, fileType: { type: String, enum: ['image', 'video', 'file', 'voice', 'location'] }, replyToId: { type: mongoose.Schema.Types.ObjectId, ref: 'ChatRoomMessage' }, createdAt: { type: Date, default: Date.now, index: true }, reactions: [ { userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, emoji: { type: String, required: true, trim: true } } ] }) module.exports = mongoose.model('ChatRoomMessage', chatRoomMessageSchema)