spring-data-dynamodb icon indicating copy to clipboard operation
spring-data-dynamodb copied to clipboard

Implement DynamoDB Auto Increment and Atomic Counter Annotations

Open darkmastermindz opened this issue 4 years ago • 1 comments

Requesting an enhancement for Dynamo DB Data Repository given variable annotated with @DynamoDBHashKey, would like to see an annotation that is @DynamoDBAutoIncrement on an integer variable where multiple instances of the same @DynamoDBHashKey can be available.

Expected Behavior

This is different use case from updating an item, rather the data pattern of putting the same item key with incremented values on a attribute, i.e. same object but different versioning (Although @DynamoDBAtomicCounter which could be another good add for an annotation as well see: https://linuxacademy.com/blog/linux-academy/dynamodb-atomic-counters/).

e.g. Suppose there's a customer with orders that earn points when purchasing x item and there's multiple order numbers under the same customer hash key, but the history of all points must be kept. This way, we can query the primary key (the customer) and the order number and the total count of orders made in history.

https://stackoverflow.com/questions/38193431/auto-increment-counter-in-dynamo-db

darkmastermindz avatar Jul 31 '20 04:07 darkmastermindz

I don't think going with an integer is a great idea with dynamodb. Due to how its indexing works (sort of a b-tree) you should always use a GUID to make sure that paritions are evenly spaces.

boostchicken avatar Aug 09 '20 06:08 boostchicken