Crates.io | clean_dynamodb_store |
lib.rs | clean_dynamodb_store |
version | 0.0.2 |
source | src |
created_at | 2024-04-01 11:29:57.849533 |
updated_at | 2024-04-01 15:36:56.57298 |
description | A library which follows clean architecture principles and provides a DynamoDB store implementation. |
homepage | |
repository | |
max_upload_size | |
id | 1192433 |
size | 4,877 |
clean_dynamodb_store
is a Rust library designed to follow clean architecture principles, offering a straightforward and efficient DynamoDB store implementation. It simplifies interactions with AWS DynamoDB, making it easier to perform common database operations such as inserting and deleting items in a DynamoDB table.
aws-sdk-dynamodb
for robust and up-to-date DynamoDB access.Before you begin, ensure you have met the following requirements:
Add clean_dynamodb_store
to your Cargo.toml
:
[dependencies]
clean_dynamodb_store = "0.0.2"
Putting an Item into a DynamoDB Table
use clean_dynamodb_store::put_item;
use aws_sdk_dynamodb::types::AttributeValue;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), aws_sdk_dynamodb::Error> {
let table_name = "your_table_name";
let mut item = HashMap::new();
item.insert("id".to_string(), AttributeValue::S("example_id".to_string()));
item.insert("content".to_string(), AttributeValue::S("Hello, world!".to_string()));
put_item(table_name, item).await?;
Ok(())
}
Deleting an Item from a DynamoDB Table
use clean_dynamodb_store::delete_item;
use aws_sdk_dynamodb::types::AttributeValue;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), aws_sdk_dynamodb::Error> {
let table_name = "your_table_name";
let mut key = HashMap::new();
key.insert("id".to_string(), AttributeValue::S("example_id".to_string()));
delete_item(table_name, key).await?;
Ok(())
}
Distributed under the MIT License. See LICENSE for more information.
Ivan Videnovic - videnovici@yahoo.com