#dynamo-db #serverless #simple #easy #logging

easy-dynamodb

A easy and simple library for interaction with DynamoDB

8 releases

0.1.7 Jan 2, 2025
0.1.6 Oct 15, 2024
0.1.1 Sep 30, 2024

#612 in Encoding

Download history 291/week @ 2024-09-25 68/week @ 2024-10-02 744/week @ 2024-10-09 163/week @ 2024-10-16 9/week @ 2024-10-23 2/week @ 2024-10-30 2/week @ 2024-11-06 4/week @ 2024-11-13 8/week @ 2024-11-20 17/week @ 2024-11-27 17/week @ 2024-12-04 18/week @ 2024-12-11 3/week @ 2024-12-25 180/week @ 2025-01-01 26/week @ 2025-01-08

209 downloads per month

MIT license

30KB
733 lines

Easy DynamoDB

Refer to test code in lib.rs

Creating a new data to DynamoDB

#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct TestModel {
    key: String,
    id: String,
    created_at: i64,
}

let client = Client::new(
    slog::Logger::root(slog::Discard, o!("goal" => "testing")),
    option_env!("AWS_ACCESS_KEY_ID")
        .expect("AWS_ACCESS_KEY_ID is required")
        .to_string(),
    option_env!("AWS_SECRET_ACCESS_KEY")
        .expect("AWS_SECRET_ACCESS_KEY is required")
        .to_string(),
    option_env!("AWS_REGION")
        .unwrap_or("ap-northeast-2")
        .to_string(),
    option_env!("AWS_DYNAMODB_TABLE")
        .expect("AWS_DYNAMODB_TABLE is required")
        .to_string(),
    option_env!("AWS_DYNAMODB_KEY").unwrap_or("key").to_string(),
    None,
    None,
)
.await
let ts = chrono::Utc::now().timestamp_nanos_opt();
assert!(ts.is_some(), "timestamp is none");
let ts = ts.unwrap();

let result = client
    .create(TestModel {
        key: format!("test_create_key-{ts}"),
        id: format!("test_create_id-{ts}"),
        created_at: ts,
    })
    .await;

Dependencies

~19–27MB
~358K SLoC