Struct bonsaidb_core::transaction::Operation
source · [−]pub struct Operation {
pub collection: CollectionName,
pub command: Command,
}Expand description
A single operation performed on a Collection.
Fields
collection: CollectionNameThe id of the Collection.
command: CommandThe command being performed.
Implementations
sourceimpl Operation
impl Operation
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 insert_serialized<C: SerializedCollection>(
id: Option<C::PrimaryKey>,
contents: &C::Contents
) -> Result<Self, Error>
pub fn insert_serialized<C: SerializedCollection>(
id: Option<C::PrimaryKey>,
contents: &C::Contents
) -> Result<Self, Error>
Inserts a new document with the serialized representation of 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 update_serialized<C: SerializedCollection>(
header: CollectionHeader<C::PrimaryKey>,
contents: &C::Contents
) -> Result<Self, Error>
pub fn update_serialized<C: SerializedCollection>(
header: CollectionHeader<C::PrimaryKey>,
contents: &C::Contents
) -> Result<Self, Error>
Updates a document with the serialized representation of contents 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 overwrite_serialized<C: SerializedCollection>(
id: C::PrimaryKey,
contents: &C::Contents
) -> Result<Self, Error>
pub fn overwrite_serialized<C: SerializedCollection>(
id: C::PrimaryKey,
contents: &C::Contents
) -> Result<Self, Error>
Overwrites a document with the serialized representation of contents
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 const fn delete(collection: CollectionName, header: Header) -> Self
pub const fn delete(collection: CollectionName, header: Header) -> Self
Deletes a document from a collection.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Operation
impl<'de> Deserialize<'de> for Operation
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
Auto Trait Implementations
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnwindSafe for Operation
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