Commit a8f6d026 authored by Balasuriya D.A.M.'s avatar Balasuriya D.A.M.

Chat Schema Backend

parent d729a8da
const mongoose = require("mongoose");
const chatModel = mongoose.Schema(
{
chatName: { type: String, trim: true },
isGroupChat: { type: Boolean, default: false },
users: [{
type: mongoose.Schema.Types.ObjectId, //contain ID to perticular user
ref: "User",
},
],
latestMessage: {
type: mongoose.Schema.Types.ObjectId, //contain ID to perticular user
ref: "Message",
},
groupAdmin: {
type: mongoose.Schema.Types.ObjectId,
ref:"User",
},
},
{
timestamps:true, // To add new chat
}
);
const Chat = mongoose.model("Chat", chatModel);
module.exports = Chat;
//chatName
//isGroupChat
//users
//latestMessage
//groupAdmin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment