Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Annotation for dynamodb enhanced client to automatically create a timestamp on for newly created object or update existing ones.

Notifications You must be signed in to change notification settings

gakinson/dyanamodb-enhanced-DynamoDbAutoGeneratedTimestamp-annotation

Repository files navigation

dyanamodb-enhanced-DynamoDbAutoGeneratedTimestamp-annotation

Annotation for dynamodb enhanced client to automatically create a timestamp on for newly created object or update existing ones.

#WARNING

  • The strategy ALWAYS does not work because DynamoDB extension WriteModification does not support update expressions, it only has updated values and a conditional expression
// When creating a client, you need to add the extension
private static final DynamoDbClient DYNAMO_CLIENT = DynamoDbClient.builder()
        .region(Region.US_WEST_2)
        .build();

private static final DynamoDbEnhancedClient CLIENT = DynamoDbEnhancedClient.builder()
        .dynamoDbClient(DYNAMO_CLIENT)
        .extensions(new AutoGeneratedTimestampExtension()) // Adding extension
        .build();



public class Customer {

    private String name;
    
    @DynamoDbAutoGeneratedTimestampAttribute(strategy = AutoGenerateStrategy.CREATE)
    private Instant joinedTimestamp;
    
    @DynamoDbAutoGeneratedTimestampAttribute(strategy = AutoGenerateStrategy.ALWAYS)
    private Instant lastUpdatedTimestamp;

}

About

Annotation for dynamodb enhanced client to automatically create a timestamp on for newly created object or update existing ones.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages