Struct bonsaidb_core::transaction::Transaction
source · [−]Expand description
A list of operations to execute as a single unit. If any operation fails, all changes are aborted. Reads that happen while the transaction is in progress will return old data and not block.
Fields
operations: Vec<Operation>The operations in this transaction.
Implementations
sourceimpl Transaction
impl Transaction
sourceimpl Transaction
impl Transaction
sourcepub fn insert(
collection: CollectionName,
id: Option<DocumentId>,
contents: impl Into<Bytes>
) -> Self
pub fn insert(
collection: CollectionName,
id: Option<DocumentId>,
contents: impl Into<Bytes>
) -> Self
Inserts a new document with contents into collection. If id is
None a unique id will be generated. If an id is provided and a
document already exists with that id, a conflict error will be returned.
sourcepub fn update(
collection: CollectionName,
header: Header,
contents: impl Into<Bytes>
) -> Self
pub fn update(
collection: CollectionName,
header: Header,
contents: impl Into<Bytes>
) -> Self
Updates a document in collection.
sourcepub fn overwrite(
collection: CollectionName,
id: DocumentId,
contents: impl Into<Bytes>
) -> Self
pub fn overwrite(
collection: CollectionName,
id: DocumentId,
contents: impl Into<Bytes>
) -> Self
Overwrites a document in collection. If a document with id exists,
it will be overwritten. If a document with id doesn’t exist, it will
be created.
sourcepub fn delete(collection: CollectionName, header: Header) -> Self
pub fn delete(collection: CollectionName, header: Header) -> Self
Deletes a document from a collection.
Trait Implementations
sourceimpl Clone for Transaction
impl Clone for Transaction
sourcefn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Transaction
impl Debug for Transaction
sourceimpl Default for Transaction
impl Default for Transaction
sourcefn default() -> Transaction
fn default() -> Transaction
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<Operation> for Transaction
impl From<Operation> for Transaction
sourceimpl Serialize for Transaction
impl Serialize for Transaction
Auto Trait Implementations
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more