'Fetching multiple data in firebase
This is the layout of my firebase database.
MyCollection > MyDocument1 > 1: Data1
> 2: Data2
> 3: Data3
> 4: Data4
> 5: Data5
> MyDocument2
> MyDocument3
I'm trying to do the multiple fetch but having a difficulty in implementing it. What am I missing?
final FirebaseFirestore db = FirebaseFirestore.instance;
DocumentSnapshot<Map<String, dynamic>> documentSnapshot = await db.collection('MyCollection').where('MyDocument1', 'in',['1','2','3']).get();
Solution 1:[1]
This is the query you execute:
db.collection('MyCollection').where('MyDocument1', 'in',['1','2','3'])
In here you are looking for a field MyDocument1 in each document in MyCollection and then check whether its value is '1','2' or '3'.
Is that indeed what you want to do? If so, can you show a screenshot from the Firebase console of a document you expect to be returned?
If you just want to read MyDocument1 that'd be:
db.collection('MyCollection').doc('MyDocument1')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

