Skip to content

Commit 1ba3635

Browse files
authored
Expand examples of reading multiple documents, to show how to process the results. (#21)
1 parent 6bfe43f commit 1ba3635

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/firebase_snippets_app/lib/snippets/firestore.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,12 @@ class FirestoreSnippets extends DocSnippet {
453453
void getDataOnce_multipleDocumentsFromACollection() {
454454
// [START get_data_once_multiple_documents_from_a_collection]
455455
db.collection("cities").where("capital", isEqualTo: true).get().then(
456-
(res) => print("Successfully completed"),
456+
(querySnapshot) {
457+
print("Successfully completed");
458+
for (var docSnapshot in querySnapshot.docs) {
459+
print('${docSnapshot.id} => ${docSnapshot.data()}');
460+
}
461+
},
457462
onError: (e) => print("Error completing: $e"),
458463
);
459464
// [END get_data_once_multiple_documents_from_a_collection]
@@ -462,7 +467,12 @@ class FirestoreSnippets extends DocSnippet {
462467
void getDataOnce_getAllDocumentsInACollection() {
463468
// [START get_data_once_get_all_documents_in_a_collection]
464469
db.collection("cities").get().then(
465-
(res) => print("Successfully completed"),
470+
(querySnapshot) {
471+
print("Successfully completed");
472+
for (var docSnapshot in querySnapshot.docs) {
473+
print('${docSnapshot.id} => ${docSnapshot.data()}');
474+
}
475+
},
466476
onError: (e) => print("Error completing: $e"),
467477
);
468478
// [END get_data_once_get_all_documents_in_a_collection]

0 commit comments

Comments
 (0)