FirebaseFirestore Framework Reference

Classes

The following classes are available globally.

  • ACollectionReference object can be used for adding documents, getting document references,and querying for documents (using the methods inherited fromQuery).

    Declaration

    Swift

    classCollectionReference:Query,@uncheckedSendable
  • Firestore represents a Firestore Database and is the entry point for all Firestoreoperations.

    Declaration

    Swift

    classFirestore:NSObject
  • ADocumentReference refers to a document location in a Firestore database and can beused to write, read, or listen to the location. The document at the referenced locationmay or may not exist. ADocumentReference can also be used to create aCollectionReference toa subcollection.

    Declaration

    Swift

    classDocumentReference:NSObject,@uncheckedSendable
  • ADocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with thedata property or by using subscript syntax to access a specific field.

    For aDocumentSnapshot that points to a non-existing document, any data access will returnnil. You can use theexists property to explicitly verify a documents existence.

    Declaration

    Swift

    classDocumentSnapshot:NSObject,@uncheckedSendable
  • Transaction provides methods to read and write data within a transaction.

    Declaration

    Swift

    classTransaction:NSObject
  • A write batch is used to perform multiple writes as a single atomic unit.

    A WriteBatch object can be acquired by callingFirestore.batch(). It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) untilWriteBatch.commit() is called.

    Unlike transactions, write batches are persisted offline and therefore are preferable when you don’t need to condition your writes on read data.

    Declaration

    Swift

    classWriteBatch:NSObject
  • Sentinel values that can be used when writing document fields withsetData() orupdateData().

    Declaration

    Swift

    classFieldValue:NSObject,@uncheckedSendable
  • Represents an aggregation that can be performed by Firestore.

    Declaration

    Swift

    classAggregateField:NSObject,@uncheckedSendable
  • A query that calculates aggregations over an underlying query.

    Declaration

    Swift

    classAggregateQuery:NSObject,@uncheckedSendable
  • The results of executing anAggregateQuery.

    Declaration

    Swift

    classAggregateQuerySnapshot:NSObject,@uncheckedSendable
  • ADocumentChange represents a change to the documents matching a query. It contains thedocument affected and the type of change that occurred (added, modified, or removed).

    Declaration

    Swift

    classDocumentChange:NSObject,@uncheckedSendable
  • AQueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with thedata property or by using subscript syntax to access a specific field.

    AQueryDocumentSnapshot offers the same API surface as aDocumentSnapshot. As deleted documents are not returned from queries, itsexists property will always be true anddata() will never returnnil.

    Declaration

    Swift

    classQueryDocumentSnapshot:DocumentSnapshot
  • AFieldPath refers to a field in a document. The path may consist of a single field name(referring to a top level field in the document), or a list of field names (referring to a nestedfield in the document).

    Declaration

    Swift

    classFieldPath:NSObject,NSCopying,@uncheckedSendable
  • A Filter represents a restriction on one or more field values and can be used to refinethe results of a Query.

    Declaration

    Swift

    classFilter:NSObject,@uncheckedSendable
  • Settings used to configure aFirestore instance.

    Declaration

    Swift

    classFirestoreSettings:NSObject,NSCopying
  • An immutable object representing a geographical point in Firestore. The point is represented as a latitude/longitude pair.

    Latitude values are in the range of [-90, 90]. Longitude values are in the range of [-180, 180].

    Declaration

    Swift

    classGeoPoint:NSObject,NSCopying,@uncheckedSendable
  • Represents a progress update or a final state from loading bundles.

    Declaration

    Swift

    classLoadBundleTaskProgress:NSObject,@uncheckedSendable
  • Represents the task of loading a Firestore bundle. Observers can be registered with this task toobserve the bundle loading progress, as well as task completion and error events.

    Declaration

    Swift

    classLoadBundleTask:NSObject
  • Configures the SDK to use a persistent cache. Firestore documents and mutations are persisted across App restart.

    This is the default cache type unless explicitly specified otherwise.

    To use, create an instance using one of the initializers, then set the instance toFirestoreSettings.cacheSettings, and useFirestoreSettings instance to configure Firestore SDK.

    Declaration

    Swift

    classPersistentCacheSettings:NSObject,NSCopying,LocalCacheSettings
  • Configures the SDK to use an eager garbage collector for memory cache.

    Once configured, the SDK will remove any Firestore documents from memory as soon as they are not used by any active queries.

    To use, create an instance using the initializer, then initializeMemoryCacheSettings with this instance. This is the default garbage collector, so alternatively you can use the default initializer ofMemoryCacheSettings.

    Declaration

    Swift

    classMemoryEagerGCSetting:NSObject,NSCopying,MemoryGarbageCollectorSettings
  • Configures the SDK to use a least-recently-used garbage collector for memory cache.

    Once configured, the SDK will attempt to remove documents that are least recently used in batches, if the current cache size is larger than the given target cache size. Default cache size is 100MB.

    To use, create an instance using one of the initializers, then initializeMemoryCacheSettings with this instance.

    Declaration

    Swift

    classMemoryLRUGCSettings:NSObject,NSCopying,MemoryGarbageCollectorSettings
  • Configures the SDK to use a memory cache. Firestore documents and mutations are NOT persisted across App restart.

    To use, create an instance using one of the initializer, then set the instance toFirestoreSettings.cacheSettings, and useFirestoreSettings instance to configure Firestore SDK.

    Declaration

    Swift

    classMemoryCacheSettings:NSObject,NSCopying,LocalCacheSettings
  • AQuery refers to a query which you can read or listen to. You can also constructrefinedQuery objects by adding filters and ordering.

    Declaration

    Swift

    classQuery:NSObject,@uncheckedSendable
  • AQuerySnapshot contains zero or moreDocumentSnapshot objects. It can be enumeratedusing thedocuments property and its size can be inspected withisEmpty andcount.

    Declaration

    Swift

    classQuerySnapshot:NSObject,@uncheckedSendable
  • Options to configure the behavior ofFirestore.addSnapshotListenerWithOptions(). Instancesof this class control settings like whether metadata-only changes trigger events and thepreferred data source.

    Declaration

    Swift

    classSnapshotListenOptions:NSObject,@uncheckedSendable
  • Metadata about a snapshot, describing the state of the snapshot.

    Declaration

    Swift

    classSnapshotMetadata:NSObject,@uncheckedSendable
  • Options to customize the behavior ofFirestore.runTransactionWithOptions().

    Declaration

    Swift

    classTransactionOptions:NSObject,NSCopying

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 2025-03-11 UTC.