socket-io: How to chat separately between chatroom creator and other user and save them on database

58
November 30, 2020, at 7:10 PM

I made a chat app, where users can join in a chatroom and when a message is sent, I am saving those messages to db.

so, that if again the users join into the chat, they can see the old messages.

but, what I want is,

  • The creator of the chatroom and the person who joins the room should see their messages. and I want to save those in DB so that they can be visible when users came back again.

  • when the another/3rd user joins the room, he should only chat with the creator of the chatroom and if he or creator of the chatroom rejoin in the chat they will see only the message betweeb him and chatroom creator.

here is my Chatroom model

const chatRoomSchema = new mongoose.Schema(
  {
    name: {
      type: String,
      required: 'Name is required',
    },
  },
  { timestamps: true }
);

and here is my message model,

const messageSchema = new mongoose.Schema(
  {
    message: {
      type: String,
      required: 'Message is required',
    },
    chatroom: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'ChatRoom',
    },
    user: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User',
    },
  },
  { timestamps: true }
);

How can I design it so that I can get separate chat between chatroom creator and other users.

READ ALSO
activate next and privous button of owl-slider using jquery

activate next and privous button of owl-slider using jquery

hello i am new in laravel i am displaying product on silder it works fine but my next and privous button is not workingHow can i work on next and previous button its customize code

85
QueryDsl instead of MongoTemplate

QueryDsl instead of MongoTemplate

Could you please help me find out how to include the mongo collection name to a QueryDsl query?

68
Javascript sort an array of strings that containing numbers

Javascript sort an array of strings that containing numbers

I'm trying to sort an array of string that sometimes contain numbers

69
Maxima Segmentation Fault PHP exec() on Ubuntu 20.04

Maxima Segmentation Fault PHP exec() on Ubuntu 20.04

Update: by redirecting stderr from php exec, I can now see that running maxima produces a segmentation fault, increasing the likelihood that this is in fact a bug

66