Since each event only has one chat, you can simplify the database logic.
3 collections required:
- Users
- Events
- Chat Messages
Create a relationship between users and events (many-to-many). Users can attend many events, events can have many users (attendees).
Also, create a relationship between events and chat messages (many-to-one). Events can have multiple chat messages, chat messages belong to one event.
There is no need for a chat collection. As soon as the user taps the join button, simply add them to the event in the update event action to add > logged in user. Then, have your button that leads to chat and set the visibility of that to sometimes if “event > users > contains > logged in user”. If the user is not added, they won’t be able to view the chat.