Coder Social home page Coder Social logo

zio-dynamodb's Introduction

zio-dynamodb

Project Stage CI Release Snapshot Discord
Project stage CI Release Artifacts Snapshot Artifacts Badge-Discord

Summary

Simple, type-safe, and efficient access to DynamoDB

Documentation

Getting Started

// only snapshots are published at the moment
resolvers += Resolver.sonatypeRepo("snapshots")

// add zio-dynamodb to your dependencies - lookup the latest snapshot version here https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-dynamodb_2.13/
libraryDependencies ++= Seq(
  // ...
  "dev.zio"               %% "zio-dynamodb"          % "0.0.1<LATEST_VERSION>"
)

For examples please see examples sbt module. Below is Main.scala from that module.

package zio.dynamodb.examples

import io.github.vigoo.zioaws.http4s
import zio.{ App, ExitCode, Has, URIO, ZLayer }
import zio.dynamodb.DynamoDBQuery.{ get, put }
import zio.dynamodb.{ DynamoDBExecutor, PrimaryKey }
import zio.schema.{ DeriveSchema, Schema }
import io.github.vigoo.zioaws.core.config
import io.github.vigoo.zioaws.dynamodb
import zio.clock.Clock

object Main extends App {

  final case class Person(id: Int, firstName: String)
  object Person {
    implicit lazy val schema: Schema[Person] = DeriveSchema.gen[Person]
  }
  val examplePerson = Person(1, "avi")

  private val program = for {
    _      <- put("tableName", examplePerson).execute
    person <- get[Person]("tableName", PrimaryKey("id" -> 1)).execute
    _      <- zio.console.putStrLn(s"hello $person")
  } yield ()

  override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = {

    val dynamoDbLayer = http4s.default >>> config.default >>> dynamodb.live // uses real AWS dynamodb
    val executorLayer = (dynamoDbLayer ++ ZLayer.identity[Has[Clock.Service]]) >>> DynamoDBExecutor.live

    program.provideCustomLayer(executorLayer).exitCode
  }
}

For examples on how to use the DynamoDBLocal in memory database please see the integration tests and StudentZioDynamoDbExample

Under the hood we use the excellent ZIO AWS library for type-safe DynamoDB access, and the awesome ZIO Schema library for schema derived codecs (see here for documentation on how to customise these through annotations).

Microsite content to come soon.

ZIO DynamoDB Microsite

Contributing

Documentation for contributors

Code of Conduct

See the Code of Conduct

Support

Come chat with us on Badge-Discord.

License

License

zio-dynamodb's People

Contributors

ghostdogpr avatar googley42 avatar nhyne avatar softinio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.