Packages

p

org

scanamo

package scanamo

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. scanamo
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait DerivedDynamoFormat extends AnyRef
  2. trait DynamoFormat[T] extends Serializable

    Type class for defining serialisation to and from DynamoDB's AttributeValue

    Type class for defining serialisation to and from DynamoDB's AttributeValue

    >>> val listOptionFormat = DynamoFormat[List[Option[Int]]]
    >>> listOptionFormat.read(listOptionFormat.write(List(Some(1), None, Some(3))))
    Right(List(Some(1), None, Some(3)))
    
    Also supports automatic and semi-automatic derivation for case classes
    >>> import org.scanamo.auto._
    >>>
    >>> case class Farm(animals: List[String])
    >>> case class Farmer(name: String, age: Long, farm: Farm)
    >>> val farmerF = DynamoFormat[Farmer]
    >>> farmerF.read(farmerF.write(Farmer("McDonald", 156L, Farm(List("sheep", "cow")))))
    Right(Farmer(McDonald,156,Farm(List(sheep, cow))))

    and for sealed trait + case object hierarchies

    >>> sealed trait Animal
    >>> case object Aardvark extends Animal
    >>> case object Zebra extends Animal
    >>> case class Pet(name: String, animal: Animal)
    >>> val petF = DynamoFormat[Pet]
    >>> petF.read(petF.write(Pet("Amy", Aardvark)))
    Right(Pet(Amy,Aardvark))
    
    >>> petF.read(petF.write(Pet("Zebediah", Zebra)))
    Right(Pet(Zebediah,Zebra))

    Problems reading a value are detailed

    >>> import cats.syntax.either._
    
    >>> case class Developer(name: String, age: String, problems: Int)
    >>> val invalid = DynamoFormat[Farmer].read(DynamoFormat[Developer].write(Developer("Alice", "none of your business", 99)))
    >>> invalid
    Left(InvalidPropertiesError(NonEmptyList(PropertyReadError(age,NoPropertyOfType(N,{S: none of your business,})), PropertyReadError(farm,MissingProperty))))
    
    >>> invalid.leftMap(cats.Show[error.DynamoReadError].show)
    Left('age': not of type: 'N' was '{S: none of your business,}', 'farm': missing)

    Optional properties are defaulted to None

    >>> case class LargelyOptional(a: Option[String], b: Option[String])
    >>> DynamoFormat[LargelyOptional].read(DynamoFormat[Map[String, String]].write(Map("b" -> "X")))
    Right(LargelyOptional(None,Some(X)))

    Custom formats can often be most easily defined using DynamoFormat.coercedXmap, DynamoFormat.xmap or DynamoFormat.iso

  3. trait EnumDynamoFormat extends LowPriorityDynamoFormat

    prop> sealed trait Animal
    prop> case object Aardvark extends Animal
    prop> case object Hippopotamus extends Animal
    prop> case object Zebra extends Animal
    
    prop> import org.scalacheck._
    prop> implicit val arbitraryAnimal: Arbitrary[Animal] = Arbitrary(Gen.oneOf(List(Aardvark, Hippopotamus, Zebra)))
    
    prop> (a: Animal) =>
        | DynamoFormat[Animal].read(DynamoFormat[Animal].write(a)) == Right(a)
    >>> DynamoFormat[Animal].write(Zebra).getS
    Zebra
  4. abstract class EnumerationDynamoFormat[T] extends DynamoFormat[T]
  5. type EvaluationKey = Map[String, AttributeValue]
  6. trait LowPriorityDynamoFormat extends AnyRef
  7. sealed abstract class SecondaryIndex[V] extends AnyRef

    Represents a secondary index on a DynamoDB table.

    Represents a secondary index on a DynamoDB table.

    Can be constructed via the index method on Table

  8. case class Table[V](name: String)(implicit evidence$1: DynamoFormat[V]) extends Product with Serializable

    Represents a DynamoDB table that operations can be performed against

    Represents a DynamoDB table that operations can be performed against

    >>> case class Transport(mode: String, line: String)
    
    >>> val client = LocalDynamoDB.client()
    >>> import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
    
    >>> LocalDynamoDB.withRandomTable(client)('mode -> S, 'line -> S) { t =>
    ...   import org.scanamo.syntax._
    ...   import org.scanamo.auto._
    ...   val transport = Table[Transport](t)
    ...   val operations = for {
    ...     _ <- transport.putAll(Set(
    ...       Transport("Underground", "Circle"),
    ...       Transport("Underground", "Metropolitan"),
    ...       Transport("Underground", "Central")))
    ...     results <- transport.query('mode -> "Underground" and ('line beginsWith "C"))
    ...   } yield results.toList
    ...   Scanamo.exec(client)(operations)
    ... }
    List(Right(Transport(Underground,Central)), Right(Transport(Underground,Circle)))

Value Members

  1. object DynamoFormat extends EnumDynamoFormat with Serializable
  2. object LocalDynamoDB
  3. object Scanamo

    Provides a simplified interface for reading and writing case classes to DynamoDB

    Provides a simplified interface for reading and writing case classes to DynamoDB

    To avoid blocking, use org.scanamo.ScanamoAsync

  4. object ScanamoAlpakka

    Provides the same interface as org.scanamo.Scanamo, except that it requires an Alpakka client and an implicit scala.concurrent.ExecutionContext and returns a scala.concurrent.Future

  5. object ScanamoAsync

    Provides the same interface as org.scanamo.Scanamo, except that it requires an implicit concurrent.ExecutionContext and returns a concurrent.Future

    Provides the same interface as org.scanamo.Scanamo, except that it requires an implicit concurrent.ExecutionContext and returns a concurrent.Future

    Note that that com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClient just uses an java.util.concurrent.ExecutorService to make calls asynchronously

  6. object ScanamoCats
  7. object ScanamoFree
  8. object ScanamoScalaz
  9. object ScanamoZio
  10. object syntax

Inherited from AnyRef

Inherited from Any

Ungrouped