toasty_core/driver/operation/
delete_by_key.rs

1use super::Operation;
2use crate::{schema::db::TableId, stmt};
3
4/// Deletes one or more records from a table by primary key.
5///
6/// Used by key-value drivers (e.g., DynamoDB). SQL drivers receive an
7/// equivalent `DELETE` statement via [`QuerySql`](super::QuerySql) instead.
8///
9/// # Examples
10///
11/// ```ignore
12/// use toasty_core::driver::operation::{DeleteByKey, Operation};
13///
14/// let op = DeleteByKey {
15///     table: table_id,
16///     keys: vec![key_value],
17///     filter: None,
18/// };
19/// let operation: Operation = op.into();
20/// ```
21#[derive(Debug, Clone)]
22pub struct DeleteByKey {
23    /// The table to delete from.
24    pub table: TableId,
25
26    /// Primary key values identifying the records to delete.
27    pub keys: Vec<stmt::Value>,
28
29    /// Optional filter expression. When set, only records whose key is in
30    /// `keys` *and* that match this filter are deleted.
31    pub filter: Option<stmt::Expr>,
32}
33
34impl From<DeleteByKey> for Operation {
35    fn from(value: DeleteByKey) -> Self {
36        Self::DeleteByKey(value)
37    }
38}