Skip to content

About

Simple, type-safe, and efficient access to DynamoDB

Topics

Resources

Stars

51 stars

Watchers

3 watching

Forks

Repository files navigation

ZIO DynamoDB

Simple, type-safe, and efficient access to DynamoDB

Development CI Badge Sonatype Releases Sonatype Snapshots javadoc ZIO DynamoDB

ZIO DynamoDB 3 is in development on the series/3.x branch. Highlights of the rewrite:

  • Effect-neutral: no longer tied to ZIO - the same queries run on ZIO, Cats Effect or Future, each through its own interpreter.
  • Modular: a small core with no AWS SDK dependency, plus a module per effect and for schema support, so you depend only on what you use.
  • High-Level API based on ZIO Blocks Schema, with derived codecs and type-safe expressions built from optics.

Snapshots are published from that branch. This branch (2.x) is in maintenance mode.

Introduction

ZIO DynamoDB is a library for type-safe, efficient and boilerplate-free access to AWS DynamoDB. We describe a read or write as a DynamoDBQuery value, combine queries, and run them with DynamoDBQuery#execute, which returns a ZIO effect. When several queries are combined, ZIO DynamoDB batches the ones DynamoDB can batch and runs the rest in parallel.

The library offers two APIs. The High Level API works with our own case classes and sealed traits. It derives the DynamoDB codecs from a ZIO Schema and builds type-checked expressions from the model's fields, so a typo in a field name or a comparison with the wrong type does not compile. The Low Level API works with DynamoDB items (Item, an attribute map) and string paths such as $("address.city"), mirroring the AWS API one to one.

Under the hood, ZIO DynamoDB calls DynamoDB through ZIO AWS, which wraps the AWS SDK for Java v2.

Installation

ZIO DynamoDB is published for Scala 2.13 and Scala 3 and runs on the JVM, Java 17 or newer. To use it, add the core module to build.sbt:

// Core: High Level and Low Level APIs, codecs and the DynamoDB executor (JVM)
libraryDependencies += "dev.zio" %% "zio-dynamodb" % "1.0.0-RC27"

The core module brings in ZIO, ZIO Streams, ZIO Schema and the ZIO AWS DynamoDB client, so no other dependency is needed to talk to DynamoDB. Continue with Getting Started to write and run a first program.

Modules

The other modules are optional. Each one depends on the core module.

Effect Interop

These modules run ZIO DynamoDB queries from code that does not use ZIO:

// Cats Effect 3 interop: run queries as F[_] effects and scans as FS2 streams (JVM)
libraryDependencies += "dev.zio" %% "zio-dynamodb-ce" % "1.0.0-RC27"

// Future interop: run queries as Scala Futures, e.g. from a Play application (JVM)
libraryDependencies += "dev.zio" %% "zio-dynamodb-future" % "1.0.0-RC27"

See How to Use ZIO DynamoDB From Cats Effect and How to Use ZIO DynamoDB From Future-Based Code.

DynamoDB JSON

This experimental module reads and writes the JSON form of DynamoDB items that the AWS CLI and Console use, which helps when debugging data mappings:

// DynamoDB JSON: render items and case classes as AWS DynamoDB JSON and parse them back (JVM)
libraryDependencies += "dev.zio" %% "zio-dynamodb-json" % "1.0.0-RC27"

See ZIO DynamoDB JSON Module.

Documentation

Learn more on the ZIO DynamoDB homepage!

Contributing

For the general guidelines, see ZIO contributor's guide.

Code of Conduct

See the Code of Conduct

Support

Come chat with us on Badge-Discord.

License

License

About

Simple, type-safe, and efficient access to DynamoDB

Topics

Resources

Stars

51 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages