DynamoDB BatchWriteItem:提供的项目键列表包含重复项 [英] DynamoDB BatchWriteItem: Provided list of item keys contains duplicates
问题描述
我正在尝试使用DynamoDB操作BatchWriteItem
,其中我想在一个表中插入多个记录.
I am trying to use DynamoDB operation BatchWriteItem
, wherein I want to insert multiple records into one table.
此表具有一个分区键和一个排序键.
This table has one partition key and one sort key.
我正在使用AWS lambda和Go语言.
I am using AWS lambda and Go language.
我得到了要插入到切片中的元素.
I get the elements to be inserted into a slice.
我正在按照此程序进行操作.
I am following this procedure.
-
创建
PutRequest
结构并为列表中的第一条记录添加AttributeValues.
Create
PutRequest
structure and add AttributeValues for the first record from the list.
我正在从此PutRequest
我正在将此WriteRequest
添加到array of WriteRequests
我正在创建BatchWriteItemInput
,它由RequestItems
组成,基本上是 Tablename的映射和WriteRequests
的数组.
I am creating BatchWriteItemInput
which consists of RequestItems
, which is basically a map of Tablename and the array of WriteRequests
.
此后,我打电话给BatchWriteItem
,这会导致错误-提供的项键列表包含重复项.
After that I am calling BatchWriteItem
, which results into an error - Provided list of item keys contains duplicates.
任何指针,为什么会发生这种情况?
Any pointers, why this could be happening?
推荐答案
您提供了两个或多个具有相同分区/排序键的项目.
You've provided two or more items with identical partition/sort keys.
根据 BatchWriteItem 文档,您无法执行多项操作在同一BatchWriteItem请求中的同一项目上.
Per the BatchWriteItem docs, you cannot perform multiple operations on the same item in the same BatchWriteItem request.
这篇关于DynamoDB BatchWriteItem:提供的项目键列表包含重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!