Skip to main content
Version: 2.x

put

def put[A: Schema](tableName: String, a: A): DynamoDBQuery[A, Option[A]] = ???

The put operation is used to insert or replace an item in a table.

for {
_ <- DynamoDBQuery.put("person", Person("1", "John", 21))
.where(Person.id.notExists) // a ConditionExpression
.execute
} yield ()

put query operationsโ€‹

<PUT_QUERY>
.returns(<ReturnValues>) // ReturnValues.AllOld | ReturnValues.None <default>
.where(<ConditionExpression>) // eg Person.id.notExists

Using put with Top level traits using discriminatorName annotationโ€‹

When using a top level sealed trait with @discriminatorName annotation, it must be provided explicitly to the put to ensure that discriminator field is encoded.

@discriminatorName("invoiceType")
sealed trait Invoice
final case class PreBilledInvoice(/* ... */) extends Invoice
final case class BilledInvoice(/* ... */) extends Invoice

for {
_ <- DynamoDBQuery.put[Invoice]("invoice", BilledInvoice(/* ... */)).execute // OK - discriminator encoded
_ <- DynamoDBQuery.put[BilledInvoice]("invoice", BilledInvoice(/* ... */)).execute // WRONG - discriminator not encoded
} yield ()

ZIO Chat

Hello! ๐Ÿ˜Š I'm your ZIO Chat Bot, designed to be your go-to resource for all things ZIO! Whether you're new to this powerful functional effect system or a seasoned pro, I'm here to assist you. ZIO empowers you to build concurrent and resilient applications in Scala, offering referential transparency, composable data types, type-safety, and more. So, go ahead and ask me anything about ZIO โ€“ I'm here to provide the answers you need! ๐Ÿค–