Skip to content

Commit

Permalink
Update firestore/app/src/main/java/com/google/example/firestore/kotli…
Browse files Browse the repository at this point in the history
…n/DocSnippets.kt

Co-authored-by: Rosário Pereira Fernandes <[email protected]>
  • Loading branch information
morganchen12 and thatfiredev committed Sep 22, 2022
1 parent 8a398ac commit 3997d38
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,16 @@ abstract class DocSnippets(val db: FirebaseFirestore) {
// [START count_aggregate_query]
val query = db.collection("games/halo/players").whereEqualTo("online", true)
val countQuery = query.count()
val snapshot = countQuery.get(AggregateSource.SERVER).result
Log.d(TAG, "Count: ${snapshot.count}");
countQuery.get(AggregateSource.SERVER).addOnCompleteListener { task ->
if (task.isSuccessful) {
// Count fetched successfully
val snapshot = task.result
Log.d(TAG, "Count: ${snapshot.count}")
} else {
Log.d(TAG, "Count failed: ", task.getException())
}
}

// [END count_aggregate_query]
}
}

0 comments on commit 3997d38

Please sign in to comment.