DocumentReference class
A DocumentReference refers 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.
A DocumentReference can also be used to create a CollectionReference to a subcollection.
See: firebase.google.com/docs/reference/js/firebase.firestore.DocumentReference.
Properties
- firestore → Firestore
-
Non-null Firestore the document is in.
This is useful for performing transactions, for example.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
The document's identifier within its collection.
no setter
- jsObject → DocumentReferenceJsImpl
-
JS object.
finalinherited
-
onMetadataChangesSnapshot
→ Stream<
DocumentSnapshot> -
Attaches a listener for DocumentSnapshot events
with
{includeMetadataChanges: true}
- raise an event even if only metadata of the document changed. Default isfalse
.no setter -
onSnapshot
→ Stream<
DocumentSnapshot> -
Attaches a listener for DocumentSnapshot events.
no setter
- parent → CollectionReference
-
Non-null CollectionReference.
The Collection this DocumentReference belongs to.
no setter
- path → String
-
The document's path within its collection.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
collection(
String collectionPath) → CollectionReference - Gets a CollectionReference instance that refers to the collection at the specified path.
-
delete(
) → Future< void> - Deletes the document referred to by this DocumentReference.
-
get(
) → Future< DocumentSnapshot> - Reads the document referred to by this DocumentReference. Note: get() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
Map< String, dynamic> data, [SetOptions? options]) → Future<void> -
Writes to the document referred to by this DocumentReference.
If the document does not exist yet, it will be created.
If you pass
options
, the provided data can be merged into the existing document. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
{Map< String, dynamic> ? data, List? fieldsAndValues}) → Future<void> - Updates fields in the document referred to by this DocumentReference. The update will fail if applied to a document that does not exist.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getInstance(
DocumentReferenceJsImpl jsObject) → DocumentReference -
Creates a new DocumentReference from a
jsObject
.