Type class for defining serialisation to and from
DynamoDB's AttributeValue
Type class for defining serialisation to and from
DynamoDB's AttributeValue
>>> val mapF = DynamoFormat[Map[String, List[Int]]] >>> mapF.read(mapF.write(Map("foo" -> List(1, 2, 3), "bar" -> List(3, 2, 1)))) Valid(Map(foo -> List(1, 2, 3), bar -> List(3, 2, 1)))
Also supports automatic derivation for case classes
>>> 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"))))) Valid(Farmer(McDonald,156,Farm(List(sheep, cow))))
Problems reading a value are detailed
>>> 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(OneAnd(PropertyReadError(age,OneAnd(NoPropertyOfType(N),List())),List(PropertyReadError(farm,OneAnd(MissingProperty,List()))))) >>> invalid.leftMap(DynamoReadError.describeAll(_)) Invalid('age': not of type: 'N', '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"))) Valid(LargelyOptional(None,Some(X)))
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 com.gu.scanamo.ScanamoAsync
Provides the same interface as com.gu.scanamo.Scanamo, except that it requires an implicit concurrent.ExecutionContext and returns a concurrent.Future
Provides the same interface as com.gu.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