#dynamo-db #aws #aws-sdk #orm #partition-key #dynamo #api-bindings

modyne

High-level crate for interacting with single-table DynamoDB instances

4 releases (2 breaking)

0.3.0 Dec 7, 2023
0.2.1 Nov 15, 2023
0.2.0 Sep 22, 2023
0.1.0 Jun 1, 2023

#448 in Database interfaces

Download history 36/week @ 2024-01-01 87/week @ 2024-01-08 19/week @ 2024-01-15 49/week @ 2024-01-22 12/week @ 2024-01-29 18/week @ 2024-02-05 80/week @ 2024-02-12 40/week @ 2024-02-19 87/week @ 2024-02-26 72/week @ 2024-03-04 163/week @ 2024-03-11 133/week @ 2024-03-18 84/week @ 2024-03-25 163/week @ 2024-04-01 183/week @ 2024-04-08 64/week @ 2024-04-15

498 downloads per month
Used in 4 crates

MIT/Apache

185KB
4.5K SLoC

Modyne

An opinionated library for interacting with AWS DynamoDB single-table designs.

docs.rs crates.io MIT/Apache-2.0 dual licensed modyne: rustc 1.70+

Motive

Modyne follows the precepts laid out for effective single-table design when working with DynamoDB, as laid out in The DynamoDB Book by Alex DeBrie and the DynamoDB Guide companion website. Such designs take advantage of the fact that certain access patterns fit very well with the relatively simple architecture of AWS DynamoDB, wherein a partition contains all the items for a given partition key within a BTree structure, sorted by a sort key.

Because of this architecture, DynamoDB rewards accessing ranges of items within a single partition through the Query operation. Additional access patterns may be enabled through global secondary indexes, and sparse indexes can be used to enable efficient Scan operations.

Leveraging single-table design, multiple different entity types can be mixed into a single DynamoDB table, and multiple entity types may cohabitate within an individual partition. Often the raw attributes of an item are not used as the keys. Instead, synthetic keys are generated from those raw attributes to support the efficient use of partitions and indexes in Query and Scan operations.

Concept

In modyne, the consumer of the crate will define their various entities in code, providing implementations for Serde serialization and deserialization, as well as providing an implementation for the Entity trait. This trait is the core of modyne. It defines the name of the entity, what attributes matter to the entity, and how the primary and any secondary index keys are generated for the entity.

The next big concepts in this crate are the QueryInput and the ProjectionSet. The query input makes it simple to define the key expression, filter expressions, and the set of attributes required by the set of projections to be read from the query. A dual to QueryInput exists for Scan operations: ScanInput.

Beyond these concepts, modyne provides higher-level fluent interfaces for interacting with these DynamoDB entities that help guide usage toward the pit of success and away from unintentional errors. The crate also provides fluent interfaces for performing bulk and transactional read and write operations as are sometimes required when keeping denormalized data in sync with a single-table design.

For a more complete tour of the functionality in this crate, see the documentation on docs.rs.


†: The MSRV for this crate can be lowered to 1.68.0 by enabling the once_cell feature.

Dependencies

~21MB
~375K SLoC