Dynorow invites you to a new way of designing your dynamodb models in rust.
This is a work in progress project. I am using this at production but you should use at your own risk. Right now I am pushing features based on my need. Please feel free to raise a PR.
dynorow is a Rust library that provides strongly typed, derive-based access to Amazon DynamoDB. It focuses on simple, compile-time-checked models with expressive update and conditional expression builders.
Conditional expression builders and filter expressions are very very WIP. I wouldn't use those now.
Features
- Derive macros for table models
- Typed insert, fetch, and update operations
- Compile-time safe key templates
- Expression builders for updates and conditions
- Nested map support
- Optional serde-based fields
- Minimal boilerplate
Upcoming Maybe
- Streams Handlers: I already have a streams handler running for my production project based on dynorow, however it is not release ready. If I see enough intreset for it, maybe I will consider cleaning it up and publishing it.
Installation
Basic Example
use HashSet;
use ;
use ;
Composite Key Templates
You can also perform matches_template on a string pk value to verify if it belongs to this model
assert!;
Some Sample Code
pub async
Derive Macros
DynoRow
Defines a DynamoDB-backed struct.
Attributes:
#[dynorow(table = ...)]– table name#[dynorow(pk = "...")]– partition key attribute name#[dynorow(pk_value = "...")]– static or templated PK value
Field attributes:
#[dynorow(sk)]– marks sort key field#[dynorow(key = "...")]– custom attribute name#[dynorow(ignore)]– excluded from DynamoDB#[dynorow(serde)]– stored using serde
DynoMap
Marks nested structs that map to DynamoDB map attributes.
Operation Traits
- Insertable – enables inserts
- Fetchable – enables gets
- Updatable – enables updates
Philosophy
- Strong typing over stringly-typed queries
- Compile-time guarantees where possible
- Simple, explicit models
- No dealing with low level aws sdk where ever possible
Dynamodb is a very capable database. I use dynamodb for its low cost when the usage is low or idle, plus scalability when I need it. Dynorow will help you keep you at your business logic level without pulling you down into low level aws sdk, where maintaing and enforcing your business rules can be very cumbersome.