I'm implementing one to one chat in firebase. I'm bit confuse with the data structure. There is best practice available for firechat, but that's for group chat not for one to one chat.
I've design the following data structure, Can anyone suggests the better way or point correction.
chat-messages/
<chat-id>
<message-id>
userId - The id of the user that sent the message.
name - The name of the user that sent the message.
message - The content of the message.
timestamp - The time at which the message was sent.
chat-metadata/
<chat-id>
createdAt - The time at which the room was created.
createdByUserId- The id of the user that created the room.
id - The id of the room.
my-chats/
<user-id>
<other-user-id>
chatId - The chat id
users/
<user-id>
id - The id of the user.
name - The display name of the user.
In my-chats
it will show the all of people user has done chatting. So for username1 and username2 there will be each entries for respective user like
my-chats
username1
username2
chatId:-K6OqUkJRDpnOahGQ4rO
username2
username1
chatId:-K6OqUkJRDpnOahGQ4rO