Skip to main content

DeleteItemRequest

Struct DeleteItemRequest 

Source
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:

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>

Source

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().await
Source§

impl<TD: TableDefinition> DeleteItemRequest<TD>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>
where TD: Send, T: Send, O: Send, R: Send, C: Send,

§

impl<TD, T, O, R, C> Sync for DeleteItemRequest<TD, T, O, R, C>
where TD: Sync, T: Sync, O: Sync, R: Sync, C: Sync,

§

impl<TD, T, O, R, C> Unpin for DeleteItemRequest<TD, T, O, R, C>
where TD: Unpin, T: Unpin, O: Unpin, R: Unpin, C: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more