Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDB Mapper: Add attribute converter annotation #1457

Open
1 task
tznd-amazon opened this issue Nov 1, 2024 · 1 comment
Open
1 task

DynamoDB Mapper: Add attribute converter annotation #1457

tznd-amazon opened this issue Nov 1, 2024 · 1 comment
Labels
dynamodb-mapper feature-request A feature should be added or improved. p2 This is a standard priority issue

Comments

@tznd-amazon
Copy link

Describe the feature

An @ConvertedBy annotation for attributes that the generator can use without defining the entire ItemConverter

Is your feature request related to a problem?

If would be great if we didn't need to define the entire Item converter when just one attribute needs a custom value converter.

Currently as documented with the DynamoDB Mapper when a custom item converter is needed a value converter must be created and then an ItemConverter needs to be created for the entire model. If I could annotate one attribute and the generator would honor it, it would save a lot of boilerplate.

Proposed Solution

@DynamoDbItem
data class Employee(
    @DynamoDbPartitionKey
    val id: Int,
    
    val name: String,
    val role: String,

    # Proposed Annotation
    @ConvertedBy(UuidValueConverter::class)
    val workstationId: Uuid,
)


public val UuidValueConverter = object : ValueConverter<Uuid> {
    override fun convertFrom(to: AttributeValue): Uuid = 
        Uuid.parseHex(to.asS())
        
    override fun convertTo(from: Uuid): AttributeValue = 
        AttributeValue.S(from.toHexString())
}

Describe alternative solutions or features you've considered

No response

Acknowledge

  • I may be able to implement this feature request

AWS SDK for Kotlin version

1.3.66-beta

Platform (JVM/JS/Native)

JVM

Operating system and version

AL2023

@tznd-amazon tznd-amazon added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 1, 2024
@lauzadis
Copy link
Member

lauzadis commented Nov 1, 2024

Thanks for this feature request, we've identified the same QoL improvement and are already tracking it!

@lauzadis lauzadis added dynamodb-mapper and removed needs-triage This issue or PR still needs to be triaged. labels Nov 1, 2024
@RanVaknin RanVaknin added the p2 This is a standard priority issue label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamodb-mapper feature-request A feature should be added or improved. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants