Reputation: 9
I'm currently making a Flutter app for practice, similar to a Twitter clone app. However, I have a problem when I try to get all documents from Firestore Database. I use UID as document id and want to see all user's posts. But only the posts of the currently logged in user are displayed.
In this case, how can I get all the documents?
I want to display posts by user [B1vq9.........] and posts by [QVf5.........].
I tried:
final FirebaseAuth auth = FirebaseAuth.instance;
final User? user = auth.currentUser;
final uid = user!.uid;
FirebaseFirestore.collection('post').doc(uid).collection('talk').snapshots();
However, this code can only display posts from the currently logged in user.
collection('talk')
is a subcollection.enter image description here
Upvotes: 0
Views: 132
Reputation: 1074
If you need all the posts from posts
's collection you only need
FirebaseFirestore.collection('post').snapshots()
If you append .doc(uid).collection('talk')
then this will fetch all the documents inside {uid}/talk
.
Upvotes: 3