Classes
The following classes are available globally.
-
Firestorerepresents a Firestore Database and is the entry point for all Firestore operations.Declaration
Swift
class Firestore : NSObject -
A
DocumentReferencerefers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. ADocumentReferencecan also be used to create aCollectionReferenceto a subcollection.Declaration
Swift
class DocumentReference : NSObject, @unchecked Sendable -
A
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
class DocumentSnapshot : NSObject, @unchecked Sendable -
Transactionprovides methods to read and write data within a transaction.Declaration
Swift
class Transaction : NSObject -
A 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
class WriteBatch : NSObject -
Sentinel values that can be used when writing document fields with
setData()orupdateData().Declaration
Swift
class FieldValue : NSObject, @unchecked Sendable -
Represents an aggregation that can be performed by Firestore.
Declaration
Swift
class AggregateField : NSObject, @unchecked Sendable -
A query that calculates aggregations over an underlying query.
Declaration
Swift
class AggregateQuery : NSObject, @unchecked Sendable -
The results of executing an
AggregateQuery.Declaration
Swift
class AggregateQuerySnapshot : NSObject, @unchecked Sendable -
A
DocumentChangerepresents a change to the documents matching a query. It contains the document affected and the type of change that occurred (added, modified, or removed).Declaration
Swift
class DocumentChange : NSObject, @unchecked Sendable -
A
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
class QueryDocumentSnapshot : DocumentSnapshot -
A
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 nested field in the document).Declaration
Swift
class FieldPath : NSObject, NSCopying, @unchecked Sendable -
A Filter represents a restriction on one or more field values and can be used to refine the results of a Query.
Declaration
Swift
class Filter : NSObject, @unchecked Sendable -
Settings used to configure a
Firestoreinstance.Declaration
Swift
class FirestoreSettings : 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
class GeoPoint : NSObject, NSCopying, @unchecked Sendable -
Represents a progress update or a final state from loading bundles.
Declaration
Swift
class LoadBundleTaskProgress : NSObject, @unchecked Sendable -
Represents the task of loading a Firestore bundle. Observers can be registered with this task to observe the bundle loading progress, as well as task completion and error events.
Declaration
Swift
class LoadBundleTask : 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 to
FirestoreSettings.cacheSettings, and useFirestoreSettingsinstance to configure Firestore SDK.Declaration
Swift
class PersistentCacheSettings : 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 initialize
MemoryCacheSettingswith this instance. This is the default garbage collector, so alternatively you can use the default initializer ofMemoryCacheSettings.Declaration
Swift
class MemoryEagerGCSetting : 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 initialize
MemoryCacheSettingswith this instance.Declaration
Swift
class MemoryLRUGCSettings : 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 to
FirestoreSettings.cacheSettings, and useFirestoreSettingsinstance to configure Firestore SDK.Declaration
Swift
class MemoryCacheSettings : NSObject, NSCopying, LocalCacheSettings -
Undocumented
Declaration
Swift
class ExprBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class FieldBridge : ExprBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class ConstantBridge : ExprBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class FunctionExprBridge : ExprBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class AggregateFunctionBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class OrderingBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class StageBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class CollectionSourceStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class DatabaseSourceStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class CollectionGroupSourceStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class DocumentsSourceStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class WhereStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class LimitStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class OffsetStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class AddFieldsStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class RemoveFieldsStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class SelectStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class DistinctStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class AggregateStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class FindNearestStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class SortStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class ReplaceWithStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class SampleStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class UnionStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class UnnestStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class RawStageBridge : StageBridge, @unchecked Sendable -
Undocumented
Declaration
Swift
class __PipelineResultBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class __PipelineResultChangeBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class __PipelineSnapshotBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class PipelineBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class __RealtimePipelineSnapshotBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class __PipelineListenOptionsBridge : NSObject, @unchecked Sendable -
Undocumented
Declaration
Swift
class RealtimePipelineBridge : NSObject, @unchecked Sendable -
A
Queryrefers to a query which you can read or listen to. You can also construct refinedQueryobjects by adding filters and ordering.Declaration
Swift
class Query : NSObject, @unchecked Sendable -
A
QuerySnapshotcontains zero or moreDocumentSnapshotobjects. It can be enumerated using thedocumentsproperty and its size can be inspected withisEmptyandcount.Declaration
Swift
class QuerySnapshot : NSObject, @unchecked Sendable -
Options to configure the behavior of
Firestore.addSnapshotListenerWithOptions(). Instances of this class control settings like whether metadata-only changes trigger events and the preferred data source.Declaration
Swift
class SnapshotListenOptions : NSObject, @unchecked Sendable -
Metadata about a snapshot, describing the state of the snapshot.
Declaration
Swift
class SnapshotMetadata : NSObject, @unchecked Sendable -
Options to customize the behavior of
Firestore.runTransactionWithOptions().Declaration
Swift
class TransactionOptions : NSObject, NSCopying -
Represents an aggregate function in a pipeline.
An
AggregateFunctionis a function that computes a single value from a set of input values.AggregateFunctions are typically used in theaggregatestage of a pipeline.Declaration
Swift
public class AggregateFunction : AggregateBridgeWrapper, @unchecked Sendable -
Represents an aggregation that counts all documents in the input set.
CountAllis used within theaggregatepipeline stage to get the total number of documents that match the query criteria up to that point.Example usage:
// Count all books in the collection firestore.pipeline() .collection("books") .aggregate([ CountAll().as("totalBooks") ]) // Count all sci-fi books published after 1960 firestore.pipeline() .collection("books") .where(Field("genre").equal("Science Fiction") && Field("published").greaterThan(1960)) .aggregate([ CountAll().as("sciFiBooksCount") ])Declaration
Swift
public class CountAll : AggregateFunction, @unchecked Sendable -
An expression that represents an array of values.
ArrayExpressionis used to construct an array from a list ofSendablevalues, which can include literals (like numbers and strings) as well as otherExpressioninstances. This allows for the creation of dynamic arrays within a pipeline.Example:
ArrayExpression([ 1, 2, Field("genre"), Field("rating").multiply(10), ArrayExpression([Field("title")]), MapExpression(["published": Field("published")]), ]).as("metadataArray")Declaration
Swift
public class ArrayExpression : FunctionExpression, @unchecked Sendable -
A
ConditionalExpressionis aFunctionExpressionthat evaluates to one of two expressions based on a boolean condition.This is equivalent to a ternary operator (
condition ? then : else).Example of using
ConditionalExpression:// Create a new field "status" based on the "rating" field. // If rating > 4.5, status is "top_rated", otherwise "regular". firestore.pipeline() .collection("products") .addFields([ ConditionalExpression( Field("rating").greaterThan(4.5), then: Constant("top_rated"), else: Constant("regular") ).as("status") ])Declaration
Swift
public class ConditionalExpression : FunctionExpression, @unchecked Sendable -
An expression that represents a server-side timestamp.
CurrentTimestampis used to generate a timestamp on the server. This is useful for recording current date and time.Example:
CurrentTimestamp().as("createdAt")Declaration
Swift
public class CurrentTimestamp : FunctionExpression, @unchecked Sendable -
An expression that produces an error with a custom error message. This is primarily used for debugging purposes.
Example:
ErrorExpression("This is a custom error message").as("errorResult")Declaration
Swift
public class ErrorExpression : FunctionExpression, @unchecked Sendable -
Represents a function call in a pipeline.
A
FunctionExpressionis an expression that represents a function call with a given name and arguments.FunctionExpressions are typically used to perform operations on data in a pipeline, such as mathematical calculations, string manipulations, or array operations.Declaration
Swift
public class FunctionExpression : Expression, BridgeWrapper, @unchecked Sendable -
An expression that represents a map (or dictionary) of key-value pairs.
MapExpressionis used to construct a map from a dictionary ofStringkeys andSendablevalues. The values can be literals (like numbers and strings) or otherExpressioninstances, allowing for the creation of dynamic nested objects within a pipeline.Example:
MapExpression([ "genre": Field("genre"), "rating": Field("rating").multiply(10), "nestedArray": ArrayExpression([Field("title")]), "nestedMap": MapExpression(["published": Field("published")]), ]).as("metadata")Declaration
Swift
public class MapExpression : FunctionExpression, @unchecked Sendable