Chat app finished

hi I have some questions about the chat app

1.should I save the the firebase users as random ids?( then the problem is I can never find a user fast) is it a bad idea to have the docs saved as names instead of random ids. but then it would get pretty messy since docs are not organized so how about only one users collection and only one doc for each user… I’m just really confused on how to structure the firebase stuff.

  1. can I make the users messages private somehow. so on the chat app when users send each other chats will this always be visible to me on firebase… I obviously don’t want it to be.

  2. how would I delete a sub collection on firebase. I made a collection with doc, and each doc has a sub collection with docs but when I delete the main collection it does not delete the subcollection.

4 I think I messed up somewhere but when I log out and log back in with a different user I see the previous users info for a sec or two before it shows and empty list.

When a document is saved to Firebase, the document ID is unique. If you have a collection of users where you are saving the name, email address, contact phone number etc, for each user, then what you could do is tell Firebase to use the currentUser uid as the document ID when creating that user entry in the users collection.

Finding the current users record in the users collection is then really easy since all you do is say something like:
let userDocument = collection("users").document(Auth.auth().currentUser?.uid)

Does that make sense?

There are some threads on stackoverflow discussing that. ie, this one:

The process of deleting a collection and a sub collection should involve checking if there are any sub collections before deleting the parent collection.

When the app loads it should ensure that the chats array is cleared before loading the chats from the current user.