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 data to the document. If the document does not exist yet, it is created. With merge options the 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 data of the document. Each key is a field path: a String (dots separate nested fields) or a FieldPath. 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 U through fromFirestore and toFirestore.
withoutConverter() → DocumentReference<Map<String, Object?>>
Returns a reference to the same document without a converter.

Operators

operator ==(Object other) → bool
The equality operator.
override

Constants

jsonType → const String
The type of the JSON representation of a reference (the same as in the main library and in the JS SDK).