- Notifications
You must be signed in to change notification settings - Fork0
Simple, type-safe, and efficient access to DynamoDB
License
sideeffffect/zio-dynamodb
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Simple, type-safe, and efficient access to DynamoDB
ZIO DynamoDB is a library that is used for type-safe, efficient, and boilerplate free access to AWS's DynamoDB service. It provides a type-safe API for many query types and the number of type-safe APIs is expanding. ZIO DynamoDB will automatically batch queries and execute unbatchable queries in parallel.
Under the hood we use the excellentZIO AWS library for type-safe DynamoDB access, and the awesomeZIO Schema library for schema derived codecs (see here for documentation on how tocustomise these through annotations).
To use ZIO DynamoDB, we need to add the following lines to ourbuild.sbt
file:
libraryDependencies++=Seq("dev.zio"%%"zio-dynamodb"%"0.2.4")
For examples please seeexamples sbt module. Below isMain.scala
from that module:
importzio.aws.core.configimportzio.aws.{dynamodb,netty }importzio.dynamodb.DynamoDBQuery.{get,put }importzio.dynamodb.{DynamoDBExecutor,PrimaryKey }importzio.schema.{DeriveSchema,Schema }importzio.ZIOAppDefaultobjectMainextendsZIOAppDefault {finalcaseclassPerson(id:Int,firstName:String)objectPerson {implicitlazyvalschema:Schema[Person]=DeriveSchema.gen[Person] }valexamplePerson=Person(1,"avi")privatevalprogram=for { _<- put("personTable", examplePerson).execute person<- get[Person]("personTable",PrimaryKey("id"->1)).execute _<- zio.Console.printLine(s"hello$person") }yield ()overridedefrun= program.provide( netty.NettyHttpClient.default, config.AwsConfig.default,// uses real AWS dynamodb dynamodb.DynamoDb.live,DynamoDBExecutor.live )}
For examples on how to use the DynamoDBLocal in memory database please see theintegration testsandStudentZioDynamoDbExample .Note before you run these you must first run the DynamoDBLocal docker container using the provided docker-compose file:
docker-compose -f docker/docker-compose.yml up -d
Don't forget to shut down the container after you have finished
docker-compose -f docker/docker-compose.yml down
Learn more on theZIO DynamoDB homepage!
For the general guidelines, see ZIOcontributor's guide.
See theCode of Conduct
About
Simple, type-safe, and efficient access to DynamoDB
Resources
License
Stars
Watchers
Forks
Packages0
Languages
- Scala100.0%