pub struct Transaction {
pub transaction_id: String,
/* private fields */
}Expand description
Represents a Firestore Transaction.
Transactions provide a way to ensure that a set of reads and writes are executed atomically.
Fields§
§transaction_id: StringImplementations§
Source§impl Transaction
impl Transaction
Sourcepub async fn get<T: DeserializeOwned>(
&self,
document_path: &str,
) -> Result<Option<T>, FirestoreError>
pub async fn get<T: DeserializeOwned>( &self, document_path: &str, ) -> Result<Option<T>, FirestoreError>
Reads the document at the given path.
The read is performed as part of the transaction.
§Arguments
document_path- The path to the document to read.
Sourcepub fn set<T: Serialize>(
&self,
document_path: &str,
value: &T,
) -> Result<&Self, FirestoreError>
pub fn set<T: Serialize>( &self, document_path: &str, value: &T, ) -> Result<&Self, FirestoreError>
Overwrites the document referred to by document_path.
If the document does not exist, it will be created. If it does exist, it will be overwritten.
§Arguments
document_path- The path to the document to write.value- The data to write.
Sourcepub fn update<T: Serialize>(
&self,
document_path: &str,
value: &T,
) -> Result<&Self, FirestoreError>
pub fn update<T: Serialize>( &self, document_path: &str, value: &T, ) -> Result<&Self, FirestoreError>
Updates fields in the document referred to by document_path.
If the document does not exist, the transaction will fail.
§Arguments
document_path- The path to the document to update.value- The data to update.
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
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 Freeze for Transaction
impl !RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl !UnwindSafe for Transaction
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