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, Global>
The operations in this transaction.
Implementations
sourceimpl Transaction
impl Transaction
sourcepub fn new() -> Transaction
pub fn new() -> Transaction
Returns a new, empty transaction.
sourcepub fn with(self, operation: Operation) -> Transaction
pub fn with(self, operation: Operation) -> Transaction
Appends an operation to the transaction and returns self.
sourceimpl Transaction
impl Transaction
sourcepub fn insert(
collection: CollectionName,
id: Option<DocumentId>,
contents: impl Into<Bytes>
) -> Transaction
pub fn insert(
collection: CollectionName,
id: Option<DocumentId>,
contents: impl Into<Bytes>
) -> Transaction
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>
) -> Transaction
pub fn update(
collection: CollectionName,
header: Header,
contents: impl Into<Bytes>
) -> Transaction
Updates a document in collection
.
sourcepub fn overwrite(
collection: CollectionName,
id: DocumentId,
contents: impl Into<Bytes>
) -> Transaction
pub fn overwrite(
collection: CollectionName,
id: DocumentId,
contents: impl Into<Bytes>
) -> Transaction
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) -> Transaction
pub fn delete(collection: CollectionName, header: Header) -> Transaction
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<Transaction, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Transaction, <__D as Deserializer<'de>>::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
sourcefn from(operation: Operation) -> Transaction
fn from(operation: Operation) -> Transaction
Performs the conversion.
sourceimpl Serialize for Transaction
impl Serialize for Transaction
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more