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();
CodePudding user response:
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')