My webapp will have chat rooms, i need to implement list of users in that chat rooms.
If array: How to update just one field in document? ( How to add user.uid to array )
If subcollection: How to get acces to subcolection in v9 firestore?
Code for creating room:
await addDoc(collection(db, "rooms"), {
creator_uid: uid,
name: _name,
secured: is_secured,
password: pass,
room_members: [],
});
Based on the official documentation the best practice would be using subcollections will work better if you have simple, fixed lists of data that you want to keep within your documents, this is easy to set up and streamlines your data structure. Here is a great google documentation that could help you with the subcollection.