FirebaseFirestore class
The entry point of Firestore Lite: a Cloud Firestore client without a local cache and without listeners. Every call is one request to the backend and one response.
final FirebaseFirestore firestore = FirebaseFirestore.instanceFor(app: app);
final DocumentSnapshot<Map<String, Object?>> city =
await firestore.doc('cities/SF').get();
Constructors
- FirebaseFirestore.instanceFor({required FirebaseApp app, String databaseId = DatabaseId.defaultDatabaseId, Settings? settings})
-
Returns the instance of
appfordatabaseId, creating it at the first call. Nothing is sent or opened until the instance is used.factory
Properties
- app → FirebaseApp
-
The app this instance belongs to.
final
- databaseId → String
-
The id of the database of this instance (
(default)for the default database), as FlutterFire'sFirebaseFirestore.databaseId.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- projectId → String
-
The ID of the project of this instance.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings ↔ Settings
-
The settings of this instance.
getter/setter pair
Methods
-
batch(
) → WriteBatch - Creates a write batch, used for performing multiple writes as a single atomic operation.
-
collection(
String collectionPath) → CollectionReference< Map< String, Object?> > -
Gets a CollectionReference that refers to the collection at
collectionPath. -
collectionGroup(
String collectionId) → Query< Map< String, Object?> > -
Creates a Query that includes all the documents in the database that
are in a collection or subcollection with the given
collectionId. -
doc(
String documentPath) → DocumentReference< Map< String, Object?> > -
Gets a DocumentReference that refers to the document at
documentPath. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
runTransaction<
T> (Future< T> updateFunction(Transaction transaction), {Duration timeout = const Duration(seconds: 30), int maxAttempts = 5, bool readOnly = false, Timestamp? readTime}) → Future<T> -
Executes
updateFunctionand then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed,updateFunctionis run again, up tomaxAttemptstimes. Aftertimeout(30 seconds by default) the returned future fails with FirestoreErrorCode.deadlineExceeded and no new attempt starts; an attempt that was committing may still take effect. -
terminate(
) → Future< void> - Terminates this instance: every later call on it, and on the references and queries made from it, fails with FirestoreErrorCode.failedPrecondition. The requests on the wire are not interrupted: the returned future completes when they are done and the connection is closed. A transaction in progress is not waited for: its next read or its commit fails (see runTransaction).
-
toString(
) → String -
A string representation of this object.
override
-
useFirestoreEmulator(
String host, int port, {bool sslEnabled = false}) → void -
Points this instance at the Firestore emulator on
hostandportuntil its first request, like the settings setter: the same assettings.withEmulator(host, port), withsslEnabledoff by default.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → FirebaseFirestore
-
The instance of the default
FirebaseAppfor its default database.no setter
Static Methods
-
setLogLevel(
LogLevel level) → void - Sets the verbosity of the Cloud Firestore logs (shared with the main library).