tempest icon indicating copy to clipboard operation
tempest copied to clipboard

Support for flattening objects

Open ansman opened this issue 4 years ago • 2 comments

The official DynamoDB mapper (at least the 2.x one) has a DynamoDbFlatten that instructs it to flatten the specified property out into a single row:

@DynamoDbBean
data class BookItem(
  @get:DynamoDbPartitionKey
  var iban: String? 
  var name: String? = null,
  @get:DynamoDbFlatten
  var author: Author? = null
) {
  @get:DynamoDbSortKey
  var sortKey: String = "book"

  @DynamoDbBean
  data class Author(
    @get:DynamoDbAttribute("authorName")
    var name: String? = null,
    @get:DynamoDbAttribute("authorNationality")
    var nationality: String? = null
  )
}

It would be nice if Tempest provided either an automatic or manual mapping of these nested types.

ansman avatar Jan 24 '21 03:01 ansman

Hmm I think your example is missing the @DynamoDbFlatten annotation?

@DynamoDbBean
data class BookItem(
  // ...
  @get:DynamoDbFlatten
  var author: Author? = null
) {
  // ...
}

zhxnlai avatar Jan 26 '21 01:01 zhxnlai

Yeah, my bad. I've updated the example

ansman avatar Jan 26 '21 12:01 ansman