I am try to design a structure for chat application include private message and
groups i by using real time firebase
i don't know how to design the structure
any help please
i am try to do something like this is that true
Users
|
|_USER1
| |
| |__FRIENDS
|
|_USER2
|
|__FRIENDS
您通常最终会在数据库中对“聊天室”进行建模。这样每个对话(用户启动应用程序时可能会看到的)都显示为某个根列表下的单独节点。您可能希望将每个对话的主要元数据与其实际消息和参与者分开。
So:
Chats
chat1
title: "...."
lastUpdated: ...
chat2
title: "...."
lastUpdated: ...
Messages
chat1
message1: { ... }
message2: { ... }
chat2
message3: { ... }
message3: { ... }
Participants
chat1
userid1: true
userid2: true
chat2
userid1: true
userid3: true
userid4: true
userid5: true
通过使用相同的键(chat1
, chat2
)对于每个列表中的节点,您可以在需要时轻松查找完整聊天的数据。但通过将它们保存在单独的顶级列表中,您可以更好地保护应用程序,并更好地控制加载的数据量。
另请参阅:
- 在 Firebase 中管理聊天频道的最佳方式
- 在 Firebase/Swift 上为两个匹配的用户创建聊天室的首选方式是什么?
- 允许用户在消息应用程序中同时向多个用户发送消息
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)