I'm attempting to make a group chat app and I want to implement the feature where it detects the number of active users in a chat room. I was thinking of updating the database with the structure below, in the viewWillAppear and viewWillDisappear functions. For example, in viewWillAppear, I would update the current user value into the chatroom node, and in viewWillDisappear, I would delete the user value; however, I was wondering if this is the most efficient way to go about this since it would require a lot of database fetching.
active_chatroom_users
- chatroomId
- UserId:1
- UserId:1