pub struct DocumentReference<'a> { /* private fields */ }Expand description
A reference to a document in a Firestore database.
Implementations§
Source§impl<'a> DocumentReference<'a>
impl<'a> DocumentReference<'a>
Sourcepub async fn get(&self) -> Result<DocumentSnapshot<'a>, FirestoreError>
pub async fn get(&self) -> Result<DocumentSnapshot<'a>, FirestoreError>
Reads the document referenced by this DocumentReference.
§Returns
A Result containing a DocumentSnapshot.
Sourcepub fn collection(&self, collection_id: &str) -> CollectionReference<'a>
pub fn collection(&self, collection_id: &str) -> CollectionReference<'a>
Gets a CollectionReference instance that refers to the subcollection at the specified path.
Sourcepub async fn list_collections(
&self,
) -> Result<Vec<CollectionReference<'a>>, FirestoreError>
pub async fn list_collections( &self, ) -> Result<Vec<CollectionReference<'a>>, FirestoreError>
Lists the subcollections of this document.
Sourcepub async fn set<T: Serialize>(
&self,
value: &T,
) -> Result<WriteResult, FirestoreError>
pub async fn set<T: Serialize>( &self, value: &T, ) -> Result<WriteResult, FirestoreError>
Writes to the document referred to by this DocumentReference.
If the document does not exist, it will be created. If it does exist, it will be overwritten.
§Arguments
value- The data to write to the document.
Sourcepub async fn update<T: Serialize>(
&self,
value: &T,
update_mask: Option<Vec<String>>,
) -> Result<WriteResult, FirestoreError>
pub async fn update<T: Serialize>( &self, value: &T, update_mask: Option<Vec<String>>, ) -> Result<WriteResult, FirestoreError>
Updates fields in the document referred to by this DocumentReference.
If the document does not exist, the update will fail.
§Arguments
value- The data to update.update_mask- An optional list of field paths to update. If provided, only the fields in the mask will be updated.
Sourcepub async fn delete(&self) -> Result<WriteResult, FirestoreError>
pub async fn delete(&self) -> Result<WriteResult, FirestoreError>
Deletes the document referred to by this DocumentReference.
Sourcepub async fn listen(&self) -> Result<ListenStream, FirestoreError>
pub async fn listen(&self) -> Result<ListenStream, FirestoreError>
Listens to changes to the document.
Trait Implementations§
Source§impl<'a> Clone for DocumentReference<'a>
impl<'a> Clone for DocumentReference<'a>
Source§fn clone(&self) -> DocumentReference<'a>
fn clone(&self) -> DocumentReference<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for DocumentReference<'a>
impl<'a> !RefUnwindSafe for DocumentReference<'a>
impl<'a> Send for DocumentReference<'a>
impl<'a> Sync for DocumentReference<'a>
impl<'a> Unpin for DocumentReference<'a>
impl<'a> !UnwindSafe for DocumentReference<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more