Skip to main content
Version: 2.x

High Level API Cheat Sheet

Note this guide assumes the reader has some basic knowledge of AWS DynamoDB API.

Assuming the below model

final case class Person(id: String, name: String, year: Int)
object Person {
implicit val schema: Schema.CaseClass3[String, String, Int, Person] = DeriveSchema.gen[Person]
val (id, name, year) = ProjectionExpression.accessors[Person]
}

For more detailed working examples please see the High Level API integration tests crud, mapping, scan and query, streaming

AWSZIO DynamoDB
GetItemperson <- get("personTable")(Person.id.partitionKey === "1").execute
UpdateItem_ <- update("personTable")(Person.id.partitionKey === "1")(Person.name.set("Foo")).execute
PutItem_ <- put('personTable', Person('42', 'John', 2020)).execute
DeleteItem_ <- deleteFrom("personTable")(Person.id.partitionKey === "1").execute
Projection ExpressionsPerson.id, Person.name, Person.year
Condition Expressions<DynamoDBQuery>.where(Person.id === "1")
Filter Expressions apply to Scan and Query<DynamoDBQuery>.filter(Person.year > 2020)
Update Expressionsupdate("personTable")(Person.id.partitionKey === "1")(Person.name.set("John") + Person.year.add(1))
Primary KeysPerson.id.partitionKey === "1" or Person.id.partitionKey === "1" && Person.year.sortKey === 2020 if table has both partition and sort keys
Key Condition Expressions<query>.whereKey(Person.id.partitionKey === "1" && Person.year.sortKey > 2020)
Expression Attribute NamesManaged automatically!
Expression Attribute ValuesManaged automatically!
Scanstream <- scanAll[Person]("personTable").execute
Scan with parallel processingstream <- scanAll[Person]("personTable").parallel(42).execute
Scan with paging(people, lastEvaluatedKey) <- scanSome[Person]("personTable", limit = 5).startKey(oldLastEvaluatedKey).execute
Querystream <- queryAll[Person]("personTable").whereKey(Person.id.partitionKey === id).execute
Query with paging(people, lastEvaluatedKey) <- querySome[Person]("personTable", limit = 5).whereKey(Person.id.partitionKey === "1").execute
BatchGetItempeople <- DynamoDBQuery.forEach(listOfIds)(id => DynamoDBQuery.get[Person]("personTable")(Person.id.partitionKey === id)).execute
BatchWriteItem_ <- DynamoDBQuery.forEach(people)(p => put("personTable", p)).execute
TransactGetItemstuple <- (get("personTable")(Person.id.partitionKey === "1") zip get("employeeTable")(Employee.id.partitionKey === "2")).transaction.execute Note transactions can span different tables.
TransactWriteItems_ <- (put("personTable", Person(1, "John", 2020)) zip put("employeeTable", Person(2, "Smith", 2024))).transaction.execute Note transactions can span different tables.