DocumentReference<T extends dynamic> class
A DocumentReference refers to a document location in a Firestore database and can be used to read or write that location. The document may or may not exist.
This is the reference of Firestore Lite: every read and write is one request to the backend. There are no listeners.
Constructors
-
DocumentReference.fromJson(FirebaseFirestore firestore, Map<
String, Object?> json, {FirestoreDataConverter<T> ? converter}) -
Creates the reference toJson wrote, for
firestore.factory
Properties
-
converter
→ FirestoreDataConverter<
T> ? -
The converter applied to the data read and written through this
reference, if any.
final
- firestore → FirebaseFirestore
-
The Firestore instance of this reference.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
The ID of the document within its collection.
no setter
-
parent
→ CollectionReference<
T> -
The collection this document is in. It keeps the converter of this
reference (as in the JS SDK; the main library of this package returns an
unconverted collection).
no setter
- path → String
-
The path of the document, relative to the root of the database.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
collection(
String collectionPath) → CollectionReference< Map< String, Object?> > -
Gets a CollectionReference to the subcollection at
collectionPath, relative to this document. -
delete(
) → Future< void> - Deletes the document. Deleting a document that does not exist succeeds.
-
get(
) → Future< DocumentSnapshot< T> > - Reads the document from the backend.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
T data, [SetOptions? options]) → Future< void> -
Writes
datato the document. If the document does not exist yet, it is created. With mergeoptionsthe data is merged into the existing document. -
toJson(
) → Map< String, Object> - A JSON representation of this reference, for DocumentReference.fromJson. The converter is not part of it.
-
toString(
) → String -
A string representation of this object.
override
-
update(
Map< Object, Object?> data) → Future<void> -
Updates the fields in
dataof the document. Each key is a field path: aString(dots separate nested fields) or aFieldPath. Fails with FirestoreErrorCode.notFound if the document does not exist. -
withConverter<
U extends Object?> ({required FromFirestore< U> fromFirestore, required ToFirestore<U> toFirestore}) → DocumentReference<U> -
Returns a reference to the same document that reads and writes objects
of type
UthroughfromFirestoreandtoFirestore. -
withoutConverter(
) → DocumentReference< Map< String, Object?> > - Returns a reference to the same document without a converter.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override