我想每次都替换现有记录,所以 putItem 对我来说是正确的操作。 但每条记录都有一个创建日期,我不想更新它。因为创建日期始终相同。
是否可以在不首先查询 DynamoDB 的情况下实现此目的?谢谢。 顺便说一句:我没有使用 DynamoDBMapper。
最佳答案
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
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)
答案: 您应该使用 UpdateItem,而不是 PutItem。
如果您确实想使用 putItem,那么您必须先查询。
关于java - 如何忽略 DynamoDB 中 putitem 中的某些字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48737816/