FirebaseFirestore Framework Reference Stay organized with collections Save and categorize content based on your preferences.
Classes
The following classes are available globally.
Firestorerepresents a Firestore Database and is the entry point for all Firestoreoperations.Declaration
Swift
classFirestore:NSObjectA
DocumentReferencerefers 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. ADocumentReferencecan also be used to create aCollectionReferencetoa subcollection.Declaration
Swift
classDocumentReference:NSObject,@uncheckedSendableA
DocumentSnapshotcontains data read from a document in your Firestore database. The data can be extracted with thedataproperty or by using subscript syntax to access a specific field.For a
DocumentSnapshotthat points to a non-existing document, any data access will returnnil. You can use theexistsproperty to explicitly verify a documents existence.Declaration
Swift
classDocumentSnapshot:NSObject,@uncheckedSendableTransactionprovides methods to read and write data within a transaction.Declaration
Swift
classTransaction:NSObjectA write batch is used to perform multiple writes as a single atomic unit.
A WriteBatch object can be acquired by calling
Firestore.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:NSObjectSentinel values that can be used when writing document fields with
setData()orupdateData().Declaration
Swift
classFieldValue:NSObject,@uncheckedSendableRepresents an aggregation that can be performed by Firestore.
Declaration
Swift
classAggregateField:NSObject,@uncheckedSendableA query that calculates aggregations over an underlying query.
Declaration
Swift
classAggregateQuery:NSObject,@uncheckedSendableThe results of executing an
AggregateQuery.Declaration
Swift
classAggregateQuerySnapshot:NSObject,@uncheckedSendableA
DocumentChangerepresents 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,@uncheckedSendableA
QueryDocumentSnapshotcontains 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 thedataproperty or by using subscript syntax to access a specific field.A
QueryDocumentSnapshotoffers the same API surface as aDocumentSnapshot. As deleted documents are not returned from queries, itsexistsproperty will always be true anddata()will never returnnil.Declaration
Swift
classQueryDocumentSnapshot:DocumentSnapshotA
FieldPathrefers 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,@uncheckedSendableA Filter represents a restriction on one or more field values and can be used to refinethe results of a Query.
Declaration
Swift
classFilter:NSObject,@uncheckedSendableSettings used to configure a
Firestoreinstance.Declaration
Swift
classFirestoreSettings:NSObject,NSCopyingAn 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,@uncheckedSendableRepresents a progress update or a final state from loading bundles.
Declaration
Swift
classLoadBundleTaskProgress:NSObject,@uncheckedSendableRepresents 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:NSObjectConfigures 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 to
FirestoreSettings.cacheSettings, and useFirestoreSettingsinstance to configure Firestore SDK.Declaration
Swift
classPersistentCacheSettings:NSObject,NSCopying,LocalCacheSettingsConfigures 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 initialize
MemoryCacheSettingswith this instance. This is the default garbage collector, so alternatively you can use the default initializer ofMemoryCacheSettings.Declaration
Swift
classMemoryEagerGCSetting:NSObject,NSCopying,MemoryGarbageCollectorSettingsConfigures 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 initialize
MemoryCacheSettingswith this instance.Declaration
Swift
classMemoryLRUGCSettings:NSObject,NSCopying,MemoryGarbageCollectorSettingsConfigures 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 to
FirestoreSettings.cacheSettings, and useFirestoreSettingsinstance to configure Firestore SDK.Declaration
Swift
classMemoryCacheSettings:NSObject,NSCopying,LocalCacheSettingsA
Queryrefers to a query which you can read or listen to. You can also constructrefinedQueryobjects by adding filters and ordering.Declaration
Swift
classQuery:NSObject,@uncheckedSendableA
QuerySnapshotcontains zero or moreDocumentSnapshotobjects. It can be enumeratedusing thedocumentsproperty and its size can be inspected withisEmptyandcount.Declaration
Swift
classQuerySnapshot:NSObject,@uncheckedSendableOptions to configure the behavior of
Firestore.addSnapshotListenerWithOptions(). Instancesof this class control settings like whether metadata-only changes trigger events and thepreferred data source.Declaration
Swift
classSnapshotListenOptions:NSObject,@uncheckedSendableMetadata about a snapshot, describing the state of the snapshot.
Declaration
Swift
classSnapshotMetadata:NSObject,@uncheckedSendableOptions to customize the behavior of
Firestore.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.