spring-data-dynamodb
spring-data-dynamodb copied to clipboard
Feature Request: Allow conditional writes
Hi Sebastian,
Awesome work on this project. I have been using it at my company with success and I have a feature request/some thoughts that I'd like to run by you.
The specific problem that I want to solve is to be able to perform conditional writes through the library https://aws.amazon.com/blogs/developer/specifying-conditional-constraints-with-amazon-dynamodb-mapper/.
I thought I could do this by using a custom repository implementation, which kind of works, but is not so nice.
Ideally, my custom repository implementation would require a DynamoDBTemplate
to be injected, and use the template to perform the conditional write. However, DynamoDBTemplate, does not expose a save method that accepts a DynamoDBSaveExpression
, which is the class that ultimately is needed by the DynamoDBMapper
for one to specify a conditional write.
Furthermore, the DynamoDBMapper that is inside the DynamoDBTemplate is not exposed in the spring context, so I cannot inject an instance of DynamoDBMapper into my custom repository either.
So, in my application, I end up creating a separate DynamoDBMapper instance that is available in my spring context, inject that into my custom repository, and then the conditional write works.
I feel like the client shouldn't be required to instantiate their own DynamoDBMapper to achieve this. I think this library can either:
- Expose the DynamoDBMapper inside DynamoDBTemplate in the spring context, or if the mapper was intentionally hidden as a design choice, then:
- Expose a save method in DynamoDBTemplate that accepts a DynamoDBSaveExpression.
Would be great to hear your thoughts on this. I'm happy to help with this issue and submit a PR based on which solution you think is better, or happy consider any other approaches as well.
Thanks, Derek
Any thoughts on this, @derjust ?
I would also see the benefits.
public void save(Object entity, DynamoDBSaveExpression saveExpression) in DynamoDBTemplate
Any issues?