DynamoDB library for Rust.
#[derive(Raiden)]
#[raiden(table_name = "user")]
pub struct User {
#[raiden(partition_key)]
id: String,
name: String,
}
#[tokio::main]
async fn main() {
let client = User::client(Region::UsEast1);
let _res = client.get("user_primary_key").run().await;
}
#[derive(Raiden)]
#[raiden(table_name = "user")]
pub struct User {
#[raiden(partition_key)]
id: String,
name: String,
}
#[tokio::main]
async fn main() {
let client = User::client(Region::UsEast1);
let input = User::put_item_builder()
.id("foo".to_owned())
.name("bokuweb".to_owned())
.build();
let res = client.put(&input).run().await;
}
#[derive(Raiden, Debug, PartialEq)]
pub struct User {
#[raiden(partition_key)]
id: String,
#[raiden(sort_key)]
year: usize,
}
#[tokio::main]
async fn main() {
let client = User::client(Region::UsEast1);
let keys: Vec<(&str, usize)> = vec![("Alice", 1992), ("Bob", 1976), ("Charlie", 2002)];
let res = client.batch_get(keys).run().await;
}
raiden
supports making span for Tracing ( span name is dynamodb::action
with table name and api name in field ).
To activate this feature, you need to specify tracing
feature in your Cargo.toml
. And your crate needs tracing
.
# Example
[dependencies]
raiden = {
tag = "0.0.76",
git = "https://github.com/raiden-rs/raiden-dynamo.git",
features = [ "tracing"]
}
tracing = "0.1"
- Rust
- Deno (1.13.2 )
- GNU Make
- Docker Engine
AWS_ACCESS_KEY_ID=awsdummy AWS_SECRET_ACCESS_KEY=awsdummy make dynamo
This starts up DynamoDB on Docker container, and then arranges test fixtures.
AWS_ACCESS_KEY_ID=awsdummy AWS_SECRET_ACCESS_KEY=awsdummy make test
NOTE: Don't recommend to use cargo test
because our test suite doesn't support running tests in parallel. Use cargo test -- --test-threads=1
instead of it.
AWS_ACCESS_KEY_ID=awsdummy AWS_SECRET_ACCESS_KEY=awsdummy cargo run --example EXAMPLE_NAME
dynamodb-admin is useful to check data in DynamoDB Local.
npx dynamodb-admin
Then open http://localhost:8001
in browser.
- BatchGetItem
- BatchWriteItem
- DeleteItem
- GetItem
- PutItem
- Query
- Scan
- TransactGetItems
- TransactWriteItems
- UpdateItem
Here is a list of unsupported features/behaviors in the actual implementation. We have a plan to resolve these issues in a future release.
This project is available under the terms of either the Apache 2.0 license or the MIT license.