简体   繁体   中英

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();

在此处输入图像描述

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM