FirebaseFirestore Framework Reference

CountAll

Represents an aggregation that counts all documents in the input set.

CountAll is used within theaggregate pipeline stage to get the total number of documentsthat match the query criteria up to that point.

Example usage:

// Count all books in the collectionfirestore.pipeline().collection("books").aggregate([CountAll().as("totalBooks")])// Count all sci-fi books published after 1960firestore.pipeline().collection("books").where(Field("genre").equal("Science Fiction")&&Field("published").greaterThan(1960)).aggregate([CountAll().as("sciFiBooksCount")])
  • Initializes a newCountAll aggregation.

    Declaration

    Swift

    publicinit()

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-13 UTC.