Bensson
Bensson

Reputation: 4589

How ignore some fields in putitem in DynamoDB

I want replace existing record each time, So putItem is right action for me. But each records have a creation date which i don't want update it. because creation date always the same.

Is any to implement this without query DynamoDB firstly? Thanks. BTW: I did not use DynamoDBMapper.

Upvotes: 1

Views: 3352

Answers (1)

F_SO_K
F_SO_K

Reputation: 14889

PutItem

Creates a new item, or replaces an old item with a new item. If an item that has the same primary key as the new item already exists in the specified table, the new item completely replaces the existing item

UpdateItem

Edits an existing item's attributes, or adds a new item to the table if it does not already exist. You can put, delete, or add attribute values. You can also perform a conditional update on an existing item (insert a new attribute name-value pair if it doesn't exist, or replace an existing name-value pair if it has certain expected attribute values)

Answer: You should be using UpdateItem, not PutItem.

If you really do want to use putItem then you have to query first.

Upvotes: 2

Related Questions