我嘗試使用 docs map 訪問子集合“匹配”。

final firestore = FirebaseFirestore.instance.collection('time').get();
firestore.docs.map((e) {
DateTime dt = e.data()['time'];
e.collection('match'); // How to access its subcollection
})
如何訪問每個檔案上的子集合“匹配”,同時訪問“時間”欄位。
uj5u.com熱心網友回復:
您的firestore變數是一個Future<QuerySnapshot>物件,您缺少awaitorthen等??待未來解決:
final firestore = FirebaseFirestore.instance.collection('time').get();
final snapshot = await firestore;
然后,您可以使用以下命令訪問每個time檔案的子集合:
snapshot.docs.map((doc) {
...
var matchCollection = doc.reference.collection('match');
})
您可能還想查看使用集合組查詢一次性讀取/查詢所有match集合。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/441429.html
