1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! # DynamoDB CRUD
//!
//! A type-safe, ergonomic interface for performing CRUD operations on Amazon DynamoDB tables.
//!
//! ## Overview
//!
//! This library provides a high-level, type-safe API for interacting with DynamoDB that:
//! - Prevents common errors at compile time through Rust's type system
//! - Offers an intuitive builder pattern for constructing operations
//! - Supports all major DynamoDB operations (Get, Put, Update, Delete, Query, Scan, Batch)
//! - Handles expression building, pagination, and error handling automatically
//!
//! ## Quick Example
//!
//! Instead of manually building DynamoDB expression strings and managing placeholders,
//! use structured types that the compiler validates:
//!
//! ```no_run
//! use aws_sdk_dynamodb::Client;
//! use dynamodb_crud::{common, write};
//! use serde_json::Value;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! # let client = Client::from_conf(aws_sdk_dynamodb::config::Config::builder().build());
//! // Complex update with multiple operations - no expression strings needed!
//! let update_item = write::update_item::UpdateItem {
//! keys: common::key::Keys {
//! partition_key: common::key::Key {
//! name: "id".to_string(),
//! value: Value::String("1".to_string()),
//! },
//! ..Default::default()
//! },
//! update_expression: write::update_item::UpdateExpressionMap::Combined(vec![
//! // SET: Update name and increment age atomically
//! write::update_item::UpdateExpressionMap::Set(
//! write::update_item::SetInputsMap::Leaves(vec![
//! ("name".to_string(), write::update_item::SetInput::Assign(Value::String("Jane".to_string()))),
//! ("age".to_string(), write::update_item::SetInput::Increment(Value::Number(1.into()))),
//! ]),
//! ),
//! // ADD: Add items to a set
//! write::update_item::UpdateExpressionMap::Add(
//! write::update_item::AddOrDeleteInputsMap::Leaves(vec![
//! ("tags".to_string(), Value::Array(vec![
//! Value::String("new".to_string()),
//! Value::String("feature".to_string()),
//! ])),
//! ]),
//! ),
//! ]),
//! write_args: write::common::WriteArgs {
//! table_name: "users".to_string(),
//! ..Default::default()
//! },
//! };
//! // The crate automatically builds: "SET #name = :set0, #age = #age + :set1 ADD #tags :add_or_delete2"
//! update_item.send(&client).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Modules
//!
//! - [`mod@common`] - Shared utilities for keys, conditions, and selections
//! - [`mod@read`] - Read operations (GetItem, Query, Scan, BatchGetItem)
//! - [`mod@write`] - Write operations (PutItem, UpdateItem, DeleteItem, BatchWriteItem)
/// Common utilities for keys, conditions, and attribute selection.
/// Read operations for retrieving data from DynamoDB tables.
///
/// This module provides operations for:
/// - Getting individual items by key
/// - Querying items with key conditions
/// - Scanning entire tables
/// - Batch retrieving multiple items
/// Write operations for modifying data in DynamoDB tables.
///
/// This module provides operations for:
/// - Putting new items or replacing existing ones
/// - Updating items with various operations (set, add, remove)
/// - Deleting items by key
/// - Batch writing multiple items