awspring / spring-cloud-aws

The New Home for Spring Cloud AWS
http://awspring.io
Apache License 2.0
855 stars 293 forks source link

Add a condition expression when inserting into DynamoDB. #1147

Open igormgomes opened 4 months ago

igormgomes commented 4 months ago

Type: Feature

Is your feature request related to a problem? Please describe. Is there a way to use a condition expression with DynamoDbOperations for inserting data, or do I need to create a separate implementation of DynamoDbTable, or should I just utilize the DynamoDbClient?

Describe the solution you'd like Perhaps we can create another method and call it like this.

var conditionalCheck = new ConditionalCheck();
conditionalCheck.setExpression(expression);
dynamoDbOperations.save(entity, conditionalCheck);

Describe alternatives you've considered I created an implementation using DynamoDbClient, and it worked.

val putItemRequest = PutItemRequest.builder()
            .tableName(tableName)
            .item(item)
            .conditionExpression("attribute_not_exists(my_sk)")
            .build();
dynamoDbClient.putItem(putItemRequest);
magnuspedro commented 4 months ago

I'm having the same issue. I looked up the doc and couldn't find anything. I had to use the same alternative as he did

arielsapatelli commented 4 months ago

I had the same problem using the conditional expressions in dynamodb operations. It would be interesting to externalize this parameter.

MatejNedic commented 4 months ago

Hey @igormgomes, thanks on reporting, I agree we should extend both operations and template with this. Are you willing to make contribution?

igormgomes commented 4 months ago

Hey @MatejNedic, thanks for replying. Yes, I'm willing.

MatejNedic commented 3 months ago

@igormgomes all yours :)

aagrawal-ipsi-ghub commented 3 months ago

@igormgomes Hi I am also facing same issue, are you working on it?