Updating an attribute in AWS DynamoDB

0 votes

Is it not possible to add an attribute in dynamodb dynamically?

I am getting an error saying “The provided key element does not match the schema".

Scenario -

{ id : "123", imageName : "elephant.jpg" }

I want to add an attribute - imagePath : "/path/to/image" to the above data. I used put_item, but it replaces the old item if exists.

Adding an attribute can be achieved using put_item but it will replace the existing item. How can we dynamically add an attribute to the existing data using update_item?

Should I alter the schema of the table with imagePath and then use the update_item function?

Nov 2, 2018 in AWS by datageek
• 3,090 points
1,898 views

1 answer to this question.

0 votes

Unfortunately, it can't be achieved in a single step. However, it can be achieved in two-step process:-

1) Try to insert the data conditionally i.e. if the key value is already present don't perform any operation (i.e. insert or update - nothing happens)

2) If there is a ConditionalCheckFailedException, then update the item

answered Nov 2, 2018 by Archana
• 5,640 points

Related Questions In AWS

0 votes
1 answer

How to add IAM role to an existing instance in aws?

As of AWS CLI v1.11.46,  you can ...READ MORE

answered Sep 6, 2018 in AWS by Archana
• 4,170 points
1,630 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer

How to make an application private on AWS Elastic Beanstalk?

Like you said by default, your application ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,640 points
2,300 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP