FirebaseFirestore Framework Reference

Protocols

The following protocols are available globally.

  • Represents a listener that can be removed by calling remove.

    Declaration

    Swift

    protocol ListenerRegistration : NSObjectProtocol
  • Marker protocol implemented by all supported cache settings.

    The two cache types supported are PersistentCacheSettings and MemoryCacheSettings. Custom implementation is not supported.

    Declaration

    Swift

    protocol LocalCacheSettings
  • Marker protocol implemented by all supported garbage collector settings.

    The two cache types supported are MemoryEagerGCSettings and MemoryLRUGCSettings. Custom implementation is not supported.

    Declaration

    Swift

    protocol MemoryGarbageCollectorSettings
  • A type that can initialize itself from a Firestore DocumentReference, which makes it suitable for use with the @DocumentID property wrapper.

    Firestore includes extensions that make String and DocumentReference conform to DocumentIDWrappable.

    Note that Firestore ignores fields annotated with @DocumentID when writing so there is no requirement to convert from the wrapped type back to a DocumentReference.

    Declaration

    Swift

    public protocol DocumentIDWrappable
  • A type that can initialize itself from a Firestore Timestamp, which makes it suitable for use with the @ServerTimestamp property wrapper.

    Firestore includes extensions that make Timestamp and Date conform to ServerTimestampWrappable.

    Declaration

    Swift

    public protocol ServerTimestampWrappable
  • Undocumented

    Declaration

    Swift

    public protocol Expression : Sendable
  • A BooleanExpression is an Expression that evaluates to a boolean value.

    It is used to construct conditional logic within Firestore pipelines, such as in where clauses or ConditionalExpression. BooleanExpression instances can be combined using standard logical operators (&&, ||, !, ^) to create complex conditions.

    Example usage in a where clause:

    firestore.pipeline()
      .collection("products")
      .where(
        Field("price").greaterThan(100) &&
        (Field("category").equal("electronics") || Field("on_sale").equal(true))
      )
    

    Declaration

    Swift

    public protocol BooleanExpression : Expression
  • A protocol for expressions that have a name.

    Selectable is adopted by expressions that can be used in pipeline stages where a named output is required, such as select and distinct.

    A Field is a Selectable where the name is the field path.

    An expression can be made Selectable by giving it an alias using the .as() method.

    Declaration

    Swift

    public protocol Selectable : Sendable
  • [Public Preview] A protocol for named values that can be computed by the addWindowFields stage.

    WindowField is adopted by AliasedAggregate (an AggregateFunction given an alias with .as()) and AliasedWindowFunction (a WindowFunction, such as Rank() or an aggregate with .over(), given an alias with .as()).

    Warning

    Window Functions SDK features are in preview until the backend feature launches. Look for the launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

    Declaration

    Swift

    public protocol WindowField : Sendable