firestore library
cloud_firestore_dart, for an app that depends on firebase_flutter_dart only. Get the
instance with FirebaseFlutter.firestore.
Classes
- AggregateField
- Represents an aggregation that can be performed by Firestore.
- AggregateQuery
- A query that calculates aggregations over the documents of a Query without downloading the documents themselves.
- AggregateQuerySnapshot
- The results of executing an AggregateQuery.
- AverageAggregateField
- Averages the values of a field over the result set.
- Blob
-
An immutable sequence of bytes, the value of a
bytesfield in a document. - BsonObjectId
- Represents a BSON ObjectId type in Firestore documents.
- BsonTimestamp
- Represents a BSON Timestamp type in Firestore documents.
- ClearableDatabase
-
A Database that deletes its own storage for
Firestore.clearPersistence. -
CollectionReference<
T extends dynamic> - A reference to a collection, used to add documents, get references to documents, and query the documents (using the methods inherited from Query).
- CountAggregateField
- Counts the documents in the result set.
- Database
- A connection to one SQLite database, returned by an OpenDatabase function. This is the only part of the SQLite layer that is public: you implement it over the SQLite binding of your choice; Firestore runs its own SQL through it.
- Decimal128Value
- Represents a 128-bit decimal type in Firestore documents.
-
DocumentChange<
T extends dynamic> - A DocumentChange represents a change to the documents matching a query. It contains the document affected and the type of change that occurred (added, modified, or removed).
-
DocumentReference<
T extends dynamic> - A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. There may or may not exist a document at the referenced location. A DocumentReference can also be used to create a CollectionReference to a subcollection.
-
DocumentSnapshot<
T extends dynamic> - A DocumentSnapshot contains data read from a document in your FirebaseFirestore database. The data can be extracted with the data or get methods.
- ExclusiveDatabase
- A Database that no other client can have open at the same time: its opener holds an exclusive lock for as long as the database is open, and the lock is released when the client is gone, however it ends (a Web Lock in a browser, as the example opener for the web takes: a page that is reloaded or closed loses it).
- FieldPath
- A FieldPath 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 nested field in the document).
- FieldValue
- Special values for writes: they tell the server how to change a field instead of giving its new value.
- Filter
-
A Filter represents a restriction on one or more field values and can be
used to refine the results of a
Query(seeQuery.where). - FirebaseFirestore
- A Cloud Firestore database, and the entry point for every Firestore operation.
-
FirestoreDataConverter<
T> -
Converts between your own model class
Tand the raw field map stored in Firestore. - GeoPoint
- A geographic point, given by its latitude and longitude in degrees.
- GetOptions
- Options of DocumentReference.get and Query.get: where the data comes from.
- IndexBackfillSettings
- The rate at which the persistent cache indexes are filled in the background, see PersistentCacheSettings.indexBackfill.
- IndexedDbCacheSettings
-
Configures a cache stored in IndexedDB in the format of the official Firebase JS SDK, on the web, without SQLite
(no
sqlite3.wasmto download, noopenDatabasefunction). - Int32Value
- Represents a 32-bit integer type in Firestore documents.
- JsSdkCacheImportResult
- The result of importJsSdkCache.
- KeyValueCacheSettings
-
Configures a persistent cache in a key-value store that the app brings (
CacheStore): an ordered store of byte keys and byte values, such as a file, an embedded database or a platform store. - LoadBundleTask
- Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.
- LoadBundleTaskSnapshot
- Represents a progress update or a final state from loading bundles.
- LocalCacheSettings
- Configures the local cache of a Firestore instance, see Settings.cacheSettings. The implementations are PersistentCacheSettings, MemoryCacheSettings, KeyValueCacheSettings and, on the web, IndexedDbCacheSettings.
- MaxKey
- Represents the Firestore "Max Key" data type, a value that sorts after every other value.
- MemoryCacheSettings
- Configures an in memory cache, which is lost when the instance is shut down. The memory cache is garbage collected as configured by gcSettings.
- MemoryEagerGcSettings
- Eager garbage collection: documents that are no longer needed by any listener or pending write are removed from the memory cache immediately.
- MemoryGarbageCollectorSettings
- Configures the garbage collector of a MemoryCacheSettings: MemoryEagerGcSettings (the default) or MemoryLruGcSettings.
- MemoryLruGcSettings
- Least recently used garbage collection: the memory cache is collected once it exceeds sizeBytes, starting with the least recently used data.
- MinKey
- Represents the Firestore "Min Key" data type, a value that sorts before every other value except null.
- PersistentCacheIndexManager
-
Controls the creation and the lifecycle of the persistent cache indexes of
a
FirebaseFirestoreinstance. - PersistentCacheSettings
- Configures a cache stored on disk (the default). The on disk cache is garbage collected once it exceeds sizeBytes.
-
Query<
T extends dynamic> - A query over the documents of a collection or a collection group, which you can read with get or listen to with snapshots.
-
QueryDocumentSnapshot<
T extends dynamic> - A QueryDocumentSnapshot 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 using the data or get methods.
-
QuerySnapshot<
T extends dynamic> - A QuerySnapshot contains the results of a query. It can contain zero or more DocumentSnapshot objects.
- RegexValue
- Represents a regular expression type in Firestore documents.
- SetOptions
-
Chooses whether a
setcall replaces the whole document or merges the data into it. - Settings
-
The settings of a
FirebaseFirestoreinstance: the backend it talks to, its local cache and its transport options. - SnapshotMetadata
- Metadata about a snapshot, describing the state of the snapshot.
- SnapshotOptions
- Options that configure how data is retrieved from a DocumentSnapshot, for example how pending server timestamps are returned. Passed to FirestoreDataConverter.fromFirestore.
- SumAggregateField
- Sums the values of a field over the result set.
- Timestamp
- A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are 'smeared' so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert to and from RFC 3339 date strings.
- Transaction
- Reads and writes documents inside a transaction started with FirebaseFirestore.runTransaction.
-
VectorQuery<
T> - A query that finds the documents whose vector field is closest to a given query vector. Create one with Query.findNearest.
-
VectorQuerySnapshot<
T> - The results of a VectorQuery, nearest document first.
- VectorValue
- A vector of doubles stored in a document field, for example an embedding for vector search.
- WebExperimentalLongPollingOptions
-
Options of the web transport (WebChannel) for when it uses long polling.
Port of
WebExperimentalLongPollingOptionsof the JS SDK. - WriteBatch
- A set of writes that Firestore applies together, as a single atomic unit: either all of them or none.
Enums
- AggregateSource
- The sources from which an AggregateQuery can retrieve its results.
- DistanceMeasure
- The distance measure used by a nearest-neighbour (vector) query.
- DocumentChangeType
- The kind of change a DocumentChange describes.
- FirestoreErrorCode
- The status code of a FirestoreException. The codes and their numeric values are the canonical gRPC status codes.
- JsSdkCacheImportRefusal
- Why importJsSdkCache or deleteJsSdkCache refused to run.
- JsSdkCacheImportStatus
- What importJsSdkCache did.
- ListenSource
-
Configures the source of snapshot listeners on
DocumentReferenceandQuery(thesourceargument ofsnapshots()). This controls how a listener retrieves data updates. - LoadBundleTaskState
- Represents the state of bundle loading tasks.
- LogLevel
-
The verbosity of the Cloud Firestore logs, set with
FirebaseFirestore.setLogLevel, from the most to the least verbose. Each level logs its own messages and those of every level after it. The JS SDK also hasinfo; the SDK writes no message at that level, so it is left out. - ServerTimestampBehavior
- Controls the return value for server timestamps that have not yet been set to their final value.
- Source
- Configures the behavior of DocumentReference.get and Query.get. By providing a Source value, these methods can be configured to fetch results only from the server, only from the local cache, or attempt to fetch results from the server and fall back to the cache (which is the default).
Functions
-
deleteJsSdkCache(
FirebaseFirestore firestore, {bool discardPendingWrites = false, String? jsAppName}) → Future< bool> -
Deletes the IndexedDB database of the official Firebase JS SDK for the app and database of
firestore(see importJsSdkCache). Returns false when there is none, or on other platforms than the web. -
importJsSdkCache(
FirebaseFirestore firestore, {bool includeDocuments = true, bool allowMemoryCache = false, String? jsAppName}) → Future< JsSdkCacheImportResult> -
Imports the cache of the official Firebase JS SDK into the cache of
firestore, once, so that a web app that used the JS SDK with persistence can switch to this SDK on the same browser profile without losing its pending writes.
Typedefs
-
BatchCallback
= Future<
void> Function(WriteBatch) - The function that FirebaseFirestore.runBatch calls with a new WriteBatch.
- Firestore = FirebaseFirestore
- The 0.1 name of FirebaseFirestore.
- FirestoreSettings = Settings
- The 0.1 name of Settings.
-
FromFirestore<
T> = T Function(DocumentSnapshot< Map< snapshot, SnapshotOptions? options)String, Object?> > -
Reads a
Tfrom the raw data of a document: thefromFirestoreargument ofwithConverter. -
OnConfigure
= Future<
void> Function(Database db) - Called by an OpenDatabase implementation first, before any migration.
-
OnCreate
= Future<
void> Function(Database db, int version) - Called by an OpenDatabase implementation when the database file is new.
-
OnOpen
= Future<
void> Function(Database db) - Called by an OpenDatabase implementation once the database is ready.
-
OnVersionChange
= Future<
void> Function(Database db, int oldVersion, int newVersion) - Called by an OpenDatabase implementation when the stored schema version differs from the requested one.
-
OpenDatabase
= Future<
Database> Function(String path, {OnConfigure onConfigure, OnCreate onCreate, OnVersionChange onDowngrade, OnOpen onOpen, OnVersionChange onUpgrade, int version}) -
Opens (creating it if needed) the SQLite database called
pathfor the offline cache. Pass one toFirebaseFirestore.instanceFor(openDatabase: ...); this package does not depend on a SQLite binding itself. Without it the cache is kept in memory only. -
ToFirestore<
T> = Map< String, Object?> Function(T value, SetOptions? options) -
Turns a
Tinto the data written for a document: thetoFirestoreargument ofwithConverter.optionsare those of thesetcall, if any. -
TransactionHandler<
T> = Future< T> Function(Transaction) - The function that FirebaseFirestore.runTransaction runs inside a transaction, and runs again for each retry.
Exceptions / Errors
- FirestoreException
- The exception thrown by Firestore operations. errorCode says what went wrong.
- JsSdkCacheImportException
- The error of importJsSdkCache and deleteJsSdkCache when they refuse to run. Nothing was imported or deleted.
- TransientDatabaseException
- Thrown by a Database when a statement failed for a reason that may go away on its own, and nothing of the failed statement (nor of the transaction it belongs to) was stored: the database was busy or locked, an I/O error occurred, the disk was full, or the storage behind the database is not reachable right now.