Dynamodb batch put if item does not exist
DynamoDb 不支持批量更新,只支持批量放置。
但是是否可以只批量放置键不存在的项目?
在
For example, you cannot specify conditions on individual put and delete requests, and BatchWriteItem does not return deleted items in the response.
相反,我建议将
[...] To prevent a new item from replacing an existing item, use a
conditional expression that contains theattribute_not_exists function
with the name of the attribute being used as the partition key for the
table [...]
所以请确保将以下内容添加到
1 2 3 4 5 6 7 8 | const params = { Item: { userId: { S:"Beyonce", } }, ConditionExpression:"attribute_not_exists(userId)" }; |