java - 如何忽略 DynamoDB 中 putitem 中的某些字段

标签 java amazon-dynamodb

我想每次都替换现有记录,所以 putItem 对我来说是正确的操作。 但每条记录都有一个创建日期,我不想更新它。因为创建日期始终相同。

是否可以在不首先查询 DynamoDB 的情况下实现此目的?谢谢。 顺便说一句:我没有使用 DynamoDBMapper。

最佳答案

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)

答案: 您应该使用 UpdateItem,而不是 PutItem。

如果您确实想使用 putItem,那么您必须先查询。

关于java - 如何忽略 DynamoDB 中 putitem 中的某些字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48737816/

相关文章:

java - Spring Data Neo4j 中的 DynamicRelationshipType 或在运行时定义关系类型

java - Android 内存泄漏堆 gc_concurrent

java - 为什么我的 Android Studio 项目无法通过 Activity 打开?

java - DynamoDB 中的批量更新

java - 找不到DynamoDB地理对象映射器类

java - 使用 Ajax 启用后退按钮

java - 使用 Class.forName(..).getInstance 时 Junit 出现 ClassNotFoundException 而 new() 工作正常

javascript - AWS Lambda 和 DynamoDB 流。执行失败怎么办?下一次尝试会处理相同的记录吗?

amazon-web-services - DynamoDB中的索引通知表

java - DynamoDB自动附加到多个列表