Krout0n / raiden-dynamo

[WIP] ⚡️ DynamoDB library for Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DynamoDB library for Rust.


Continuous Integration

Examples

get_item example

#[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;
}

put_item example

#[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;
}

batch_get_item example

#[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;
}

Development

Requirements

  • Rust
  • Deno (1.13.2+)
  • GNU Make
  • Docker Engine

Setup

make dynamo

This starts up DynamoDB on Docker container, and then arranges test fixtures.

Test

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.

Utility

dynamodb-admin is useful to check data in DynamoDB Local.

npx dynamodb-admin

Then open http://localhost:8001 in browser.

Supported APIs

Item

  • BatchGetItem
  • BatchWriteItem
  • DeleteItem
  • GetItem
  • PutItem
  • Query
  • Scan
  • TransactGetItems
  • TransactWriteItems
  • UpdateItem

Known limitations

Here is a list of unsupported features/behaviors in the actual implementation. We have a plan to resolve these issues in a future release.

About

[WIP] ⚡️ DynamoDB library for Rust.


Languages

Language:Rust 92.8%Language:TypeScript 7.1%Language:Makefile 0.1%