I'm looking to build a simple chat app using Flutter + Firestore, storing users and chats in separate collections. Each chat document has two string fields [uid1, uid2] representing the user ids of the respective participants. I need to be able to search for all chats for a given user (uid) so some type of OR query, this would be possible by storing them in an array field and using array_contains.
However, to update a chat document, I need to be able to query on both fields directly to retrieve a specific chat between two users, which would not be possible using the array approach (nested array_contains are not allowed). Even storing both as two top-level string fields requires two firestore queries for either direction.
Appreciate any advice on how to solve this limitation of Firestore queries?