Firebase. Firestore. DocumentReference
ADocumentReference refers to a document location in a CloudFirestore database and can be used to write, read, or listen to the location.
Summary
There may or may not exist a document at the referenced location. ADocumentReference can also be used to create aCollectionReference to a subcollection.
Inheritance
Inherits from: IEquatable< DocumentReference >Properties | |
|---|---|
Firestore | The database which contains the document. |
Public attributes | |
|---|---|
Id => _proxy.id() | stringThe final part of the complete document path; this is the identity of the document relative to its parent collection. |
Parent => new CollectionReference(_proxy.Parent(), Firestore) | The parent collection. |
Path => _proxy.path() | stringThe complete document path, not including project and database ID. |
Public functions | |
|---|---|
Collection(string path) | Creates aCollectionReference for a child collection of this document. |
DeleteAsync() | TaskAsynchronously deletes the document referred to by this DocumentReference. |
Equals(object obj) | override bool |
Equals(DocumentReference other) | bool |
GetHashCode() | override int |
GetSnapshotAsync(Source source) | Task<DocumentSnapshot >Asynchronously fetches a snapshot of the document. |
Listen(Action<DocumentSnapshot > callback) | Starts listening to changes to the document referenced by this DocumentReference. |
Listen(MetadataChanges metadataChanges, Action<DocumentSnapshot > callback) | Starts listening to changes to the document referenced by this DocumentReference. |
SetAsync(object documentData,SetOptions options) | TaskAsynchronously sets data in the document, either replacing it completely or merging fields. |
ToString() | override string |
UpdateAsync(IDictionary< string, object > updates) | TaskAsynchronously performs a set of updates on the document referred to by this DocumentReference. |
UpdateAsync(string field, object value) | TaskAsynchronously performs a single field update on the document referred to by this DocumentReference. |
UpdateAsync(IDictionary<FieldPath, object > updates) | TaskAsynchronously performs a set of updates on the document referred to by this DocumentReference. |
Properties
Public attributes
Id
stringId=>_proxy.id()
The final part of the complete document path; this is the identity of the document relative to its parent collection.
Parent
CollectionReferenceParent=>newCollectionReference(_proxy.Parent(),Firestore)
The parent collection.
Nevernull.
Path
stringPath=>_proxy.path()
The complete document path, not including project and database ID.
Public functions
Collection
CollectionReferenceCollection(stringpath)
Creates aCollectionReference for a child collection of this document.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | ACollectionReference for the specified collection. |
DeleteAsync
TaskDeleteAsync()
Asynchronously deletes the document referred to by thisDocumentReference.
| Details | |
|---|---|
| Returns | The write result of the server operation. The task will not complete while the client is offline, though local changes will be visible immediately. |
Equals
overrideboolEquals(objectobj)
Equals
boolEquals(DocumentReferenceother)
GetHashCode
overrideintGetHashCode()
GetSnapshotAsync
Task<DocumentSnapshot>GetSnapshotAsync(Sourcesource)
Asynchronously fetches a snapshot of the document.
By default,GetSnapshotAsync 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. This behavior can be altered via thesource parameter.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | A snapshot of the document. The snapshot may represent a missing document. |
Listen
ListenerRegistrationListen(Action<DocumentSnapshot>callback)
Starts listening to changes to the document referenced by thisDocumentReference.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | AListenerRegistration which may be used to stop listening gracefully. |
Listen
ListenerRegistrationListen(MetadataChangesmetadataChanges,Action<DocumentSnapshot>callback)
Starts listening to changes to the document referenced by thisDocumentReference.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | AListenerRegistration which may be used to stop listening gracefully. |
SetAsync
TaskSetAsync(objectdocumentData,SetOptionsoptions)
Asynchronously sets data in the document, either replacing it completely or merging fields.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | The write result of the server operation. The task will not complete while the client is offline, though local changes will be visible immediately. |
ToString
overridestringToString()
UpdateAsync
TaskUpdateAsync(IDictionary<string,object>updates)
Asynchronously performs a set of updates on the document referred to by thisDocumentReference.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The write result of the server operation. The task will not complete while the client is offline, though local changes will be visible immediately. |
UpdateAsync
TaskUpdateAsync(stringfield,objectvalue)
Asynchronously performs a single field update on the document referred to by thisDocumentReference.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | The write result of the server operation. The task will not complete while the client is offline, though local changes will be visible immediately. |
UpdateAsync
TaskUpdateAsync(IDictionary<FieldPath,object>updates)
Asynchronously performs a set of updates on the document referred to by thisDocumentReference.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The write result of the server operation. The task will not complete while the client is offline, though local changes will be visible immediately. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.