pub struct DeleteItemRequest<TD: TableDefinition, T = (), O: OutputFormat = Raw, R: ReturnValue = ReturnNothing, C: ConditionState = NoCondition> { /* private fields */ }Expand description
Builder for a DynamoDB DeleteItem request.
Constructed via DynamoDBItemOp::delete / DynamoDBItemOp::delete_by_id
(typed, with a concrete T) or DeleteItemRequest::new (stand-alone,
raw output). The builder provides:
- Output format — the result can be deserialized into
T. Call.raw()to receive an untypedItem<TD>instead (one-way). - Return value — Call
.return_old()to request the deleted item, or.return_none()to return nothing. - Condition — optionally add a guard expression via
.condition(), or.exists().
The builder implements IntoFuture, so it can
be .awaited directly.
§Errors
Returns Err if the DynamoDB request fails or if a condition
expression is set and the check fails
(ConditionalCheckFailedException).
§Examples
use dynamodb_facade::{DynamoDBItemOp, Condition, KeyId};
let enrollment = sample_enrollment();
// Simple delete
enrollment.delete(client).await?;
// Delete only if the item exists
enrollment.delete(client).exists().await?;
// Delete with a custom condition
enrollment
.delete(client)
.condition(Enrollment::exists() & Condition::not_exists("completed_at"))
.await?;
// Delete and return the old item
let old /* : Option<Enrollment> */ = enrollment.delete(client).return_old().await?;
// Delete by ID and return the old item
let old /* : Option<Enrollment> */ = Enrollment::delete_by_id(
client,
KeyId::pk("user-1").sk("course-42"),
)
.await?;Implementations§
Source§impl<TD: TableDefinition, T, O: OutputFormat, R: ReturnValue, C: ConditionState> DeleteItemRequest<TD, T, O, R, C>
impl<TD: TableDefinition, T, O: OutputFormat, R: ReturnValue, C: ConditionState> DeleteItemRequest<TD, T, O, R, C>
Sourcepub fn into_inner(self) -> DeleteItemFluentBuilder
pub fn into_inner(self) -> DeleteItemFluentBuilder
Consumes the builder and returns the underlying SDK
DeleteItemFluentBuilder.
Use this escape hatch when you need to set options not exposed by this facade, or when integrating with code that expects the raw SDK builder.
§Examples
use dynamodb_facade::DynamoDBItemOp;
let sdk_builder = sample_enrollment().delete(client).into_inner();
// configure sdk_builder further, then call .send().awaitSource§impl<TD: TableDefinition> DeleteItemRequest<TD>
impl<TD: TableDefinition> DeleteItemRequest<TD>
Sourcepub fn new(client: Client, key: Key<TD>) -> Self
pub fn new(client: Client, key: Key<TD>) -> Self
Creates a stand-alone DeleteItemRequest with raw output (T = (), O = Raw).
Use this when you already have a Key<TD> and do not need typed
deserialization of the deleted value. For typed access, prefer
DynamoDBItemOp::delete or DynamoDBItemOp::delete_by_id instead.
§Examples
use dynamodb_facade::DeleteItemRequest;
let key = sample_user_item().into_key_only();
DeleteItemRequest::<PlatformTable>::new(client, key).await?;Source§impl<TD: TableDefinition, T, O: OutputFormat, C: ConditionState> DeleteItemRequest<TD, T, O, ReturnNothing, C>
impl<TD: TableDefinition, T, O: OutputFormat, C: ConditionState> DeleteItemRequest<TD, T, O, ReturnNothing, C>
Sourcepub fn return_old(self) -> DeleteItemRequest<TD, T, O, Return<Old>, C>
pub fn return_old(self) -> DeleteItemRequest<TD, T, O, Return<Old>, C>
Requests that DynamoDB return the item’s attributes before deletion.
When executed, execute returns
Option<T> (typed) or Option<Item<TD>> (raw) — None if no item
existed at that key.
Use .return_none() to revert.
§Examples
use dynamodb_facade::DynamoDBItemOp;
let old /* : Option<Enrollment> */ = sample_enrollment()
.delete(client)
.return_old()
.await?;Source§impl<TD: TableDefinition, T, O: OutputFormat, C: ConditionState> DeleteItemRequest<TD, T, O, Return<Old>, C>
impl<TD: TableDefinition, T, O: OutputFormat, C: ConditionState> DeleteItemRequest<TD, T, O, Return<Old>, C>
Sourcepub fn return_none(self) -> DeleteItemRequest<TD, T, O, ReturnNothing, C>
pub fn return_none(self) -> DeleteItemRequest<TD, T, O, ReturnNothing, C>
Reverts the return-value setting so that nothing is returned.
After this call, execute returns ()
instead of the deleted item.
§Examples
use dynamodb_facade::{DynamoDBItemOp, KeyId};
// delete_by_id defaults to Return<Old>; opt out with return_none
Enrollment::delete_by_id(client, KeyId::pk("user-1").sk("course-42"))
.return_none()
.await?;Source§impl<TD: TableDefinition, T, O: OutputFormat, R: ReturnValue> DeleteItemRequest<TD, T, O, R, NoCondition>
impl<TD: TableDefinition, T, O: OutputFormat, R: ReturnValue> DeleteItemRequest<TD, T, O, R, NoCondition>
Sourcepub fn condition(
self,
condition: Condition<'_>,
) -> DeleteItemRequest<TD, T, O, R, AlreadyHasCondition>
pub fn condition( self, condition: Condition<'_>, ) -> DeleteItemRequest<TD, T, O, R, AlreadyHasCondition>
Adds a condition expression that must be satisfied for the delete to succeed.
DynamoDB accepts a single condition expression per request, so this
method can only be called once. If the condition fails at runtime,
DynamoDB returns a ConditionalCheckFailedException.
For the common item exists case, prefer the
.exists() shorthands.
§Examples
use dynamodb_facade::{DynamoDBItemOp, Condition};
// Delete only if the enrollment has not been completed
sample_enrollment()
.delete(client)
.condition(Enrollment::exists() & Condition::not_exists("completed_at"))
.await?;Source§impl<TD: TableDefinition, T: DynamoDBItem<TD>, O: OutputFormat, R: ReturnValue> DeleteItemRequest<TD, T, O, R, NoCondition>
impl<TD: TableDefinition, T: DynamoDBItem<TD>, O: OutputFormat, R: ReturnValue> DeleteItemRequest<TD, T, O, R, NoCondition>
Sourcepub fn exists(self) -> DeleteItemRequest<TD, T, O, R, AlreadyHasCondition>
pub fn exists(self) -> DeleteItemRequest<TD, T, O, R, AlreadyHasCondition>
Adds an attribute_exists(<PK>) condition, requiring the item to exist before deletion.
The delete fails with ConditionalCheckFailedException if the item does not exist.
§Examples
use dynamodb_facade::DynamoDBItemOp;
sample_enrollment().delete(client).exists().await?;Source§impl<TD: TableDefinition, T, R: ReturnValue, C: ConditionState> DeleteItemRequest<TD, T, Typed, R, C>
impl<TD: TableDefinition, T, R: ReturnValue, C: ConditionState> DeleteItemRequest<TD, T, Typed, R, C>
Sourcepub fn raw(self) -> DeleteItemRequest<TD, T, Raw, R, C>
pub fn raw(self) -> DeleteItemRequest<TD, T, Raw, R, C>
Switches the output format from Typed to Raw.
After calling .raw(), execute returns
Option<Item<TD>> instead of Option<T> when Return<Old> is active.
This transition is one-way.
§Examples
use dynamodb_facade::DynamoDBItemOp;
let old_raw /* : Option<Item<PlatformTable>> */ =
sample_enrollment()
.delete(client)
.return_old()
.raw()
.await?;Source§impl<TD: TableDefinition, T, O: OutputFormat, C: ConditionState> DeleteItemRequest<TD, T, O, ReturnNothing, C>
impl<TD: TableDefinition, T, O: OutputFormat, C: ConditionState> DeleteItemRequest<TD, T, O, ReturnNothing, C>
Sourcepub fn execute(self) -> impl Future<Output = Result<()>> + Send + 'static
pub fn execute(self) -> impl Future<Output = Result<()>> + Send + 'static
Sends the DeleteItem request, returning nothing on success.
This method is also available implicitly via .await.
§Errors
Returns Err if the DynamoDB request fails or if a condition
expression is set and the check fails
(ConditionalCheckFailedException).
§Examples
use dynamodb_facade::DynamoDBItemOp;
sample_enrollment().delete(client).exists().execute().await?;Source§impl<TD: TableDefinition, T: DynamoDBItem<TD> + DeserializeOwned, C: ConditionState> DeleteItemRequest<TD, T, Typed, Return<Old>, C>
impl<TD: TableDefinition, T: DynamoDBItem<TD> + DeserializeOwned, C: ConditionState> DeleteItemRequest<TD, T, Typed, Return<Old>, C>
Sourcepub fn execute(self) -> impl Future<Output = Result<Option<T>>> + Send + 'static
pub fn execute(self) -> impl Future<Output = Result<Option<T>>> + Send + 'static
Sends the DeleteItem request and returns the deleted item deserialized as T.
Returns Ok(None) if no item existed at the key.
This method is also available implicitly via .await.
§Errors
Returns Err if the DynamoDB request fails, if a condition check
fails, or if deserialization of the returned attributes fails.
§Examples
use dynamodb_facade::{DynamoDBItemOp, KeyId};
let old /* : Option<Enrollment> */ = Enrollment::delete_by_id(
client,
KeyId::pk("user-1").sk("course-42"),
)
.execute()
.await?;Source§impl<TD: TableDefinition, T, C: ConditionState> DeleteItemRequest<TD, T, Raw, Return<Old>, C>
impl<TD: TableDefinition, T, C: ConditionState> DeleteItemRequest<TD, T, Raw, Return<Old>, C>
Sourcepub fn execute(
self,
) -> impl Future<Output = Result<Option<Item<TD>>>> + Send + 'static
pub fn execute( self, ) -> impl Future<Output = Result<Option<Item<TD>>>> + Send + 'static
Sends the DeleteItem request and returns the deleted raw item map.
Returns Ok(None) if no item existed at the key.
This method is also available implicitly via .await.
§Errors
Returns Err if the DynamoDB request fails or if a condition check
fails.
§Examples
use dynamodb_facade::DynamoDBItemOp;
let old_raw = sample_enrollment()
.delete(client)
.return_old()
.raw()
.execute()
.await?;
// old_raw: Option<Item<PlatformTable>>Auto Trait Implementations§
impl<TD, T, O, R, C> Freeze for DeleteItemRequest<TD, T, O, R, C>
impl<TD, T = (), O = Raw, R = ReturnNothing, C = NoCondition> !RefUnwindSafe for DeleteItemRequest<TD, T, O, R, C>
impl<TD, T, O, R, C> Send for DeleteItemRequest<TD, T, O, R, C>
impl<TD, T, O, R, C> Sync for DeleteItemRequest<TD, T, O, R, C>
impl<TD, T, O, R, C> Unpin for DeleteItemRequest<TD, T, O, R, C>
impl<TD, T, O, R, C> UnsafeUnpin for DeleteItemRequest<TD, T, O, R, C>
impl<TD, T = (), O = Raw, R = ReturnNothing, C = NoCondition> !UnwindSafe for DeleteItemRequest<TD, T, O, R, C>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more