Skip to main content

vantage_aws/dynamodb/
operation.rs

1//! DynamoDB operation trait — typed `.eq()`/`.gt()`/… methods producing
2//! `DynamoCondition`. Blanket-implemented over `Expressive<T>` so columns
3//! pick up these methods for free.
4//!
5//! v0 only wires `.eq()`. The richer set (`.gt`, `.between`, `.in_`,
6//! `.begins_with`) lands alongside `Scan`/`Query` filter execution.
7
8use vantage_expressions::Expressive;
9
10use super::condition::DynamoCondition;
11use super::types::AnyDynamoType;
12
13fn field_name<T>(expr: &(impl Expressive<T> + ?Sized)) -> String {
14    expr.expr().template
15}
16
17pub trait DynamoOperation<T>: Expressive<T> {
18    /// `field = :value` — see `DynamoCondition::eq`.
19    fn eq(&self, value: impl Into<AnyDynamoType>) -> DynamoCondition
20    where
21        Self: Sized,
22    {
23        let any: AnyDynamoType = value.into();
24        DynamoCondition::eq(field_name(self), any.into_value())
25    }
26}
27
28impl<T, S: Expressive<T>> DynamoOperation<T> for S {}