const mongoose = require("mongoose");
const { Schema } = mongoose;

const messageSchema = mongoose.Schema({
  senderId: {
    type: String,
    required: true,
  },
  receiverId: {
    type: String,
    required: true,
  },
  message: {
    type: String,
  },
  date: {
    type: Date,
    default: Date.now(),
  },
  chatWith: {
    type: String,
   
  },
 sender: { 
  type: mongoose.Schema.Types.ObjectId, 
  ref: "user" 
},
 receiver: { 
  type: mongoose.Schema.Types.ObjectId, 
  ref: "user" 
},
});

module.exports = mongoose.model("message", messageSchema);
