void QuickstartReadData()

in firestore/android/FirestoreSnippetsCpp/app/src/main/cpp/snippets.cpp [119:143]


void QuickstartReadData(firebase::firestore::Firestore* db) {
  using firebase::Future;
  using firebase::firestore::DocumentSnapshot;
  using firebase::firestore::Error;
  using firebase::firestore::FieldValue;
  using firebase::firestore::QuerySnapshot;

  // To quickly verify that you've added data to Firestore, use the data
  // viewer in the Firebase console.
  //
  // You can also use the "Get" method to retrieve the entire collection.
  // [START get_collection]
  Future<QuerySnapshot> users = db->Collection("users").Get();
  users.OnCompletion([](const Future<QuerySnapshot>& future) {
    if (future.error() == Error::kErrorOk) {
      for (const DocumentSnapshot& document : future.result()->documents()) {
        std::cout << document << std::endl;
      }
    } else {
      std::cout << "Error getting documents: " << future.error_message()
                << std::endl;
    }
  });
  // [END get_collection]
}