A DynamoDB abstraction for Rust
Deez is a DynamoDB abstraction for implementing Single Table Design easily, inspired by ElectroDB.
Getting Started
Define a schema for your entities using the Deez procedural macro. Doing so
will derive the From conversion traits for your structs and the
HashMap<String, AttributeValue> type used by the aws_sdk_dynamodb library,
with some additional features for facilitating Single Table Design.
use AttributeValue;
use *;
use HashMap;
use Uuid;
Now you can convert your struct to a HashMap that you can pass directly to the
DynamoDB client.
let task = Task ;
let map: = task.into;
println!;
// keys are generated based on schema!
// output:
// {
// "pk": S("$TaskService#Task#task_id_1885ea1d-e296-4c0f-9fbf-863b1318c698"), <-
// "sk": S("$Task#employee_e42069#project_foo_project"), <-
// "gsi1pk": S("$TaskService#Task#project_foo_project"), <-
// "gsi1sk": S("$Task#employee_e42069#task_id_1885ea1d-e296-4c0f-9fbf-863b1318c698"), <-
// "gsi2pk": S("$TaskService#Task#employee_e42069"), <-
// "gsi2sk": S("$Task#project_foo_project#task_id_1885ea1d-e296-4c0f-9fbf-863b1318c698"), <-
// "task_id": S("1885ea1d-e296-4c0f-9fbf-863b1318c698"),
// "project": S("foo_project"),
// "employee": S("e42069"),
// "description": S("nothin' but chillin' 20's"),
// }
The following example shows a practical use-case interacting with DynamoDB client:
use Result;
use Client;
async
Getting Shwifty (Aware)
I highly recommend you peruse the tests folder for more usage examples, as the
generated docs for macros won't be very helpful.