首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以使用BatchPutItem (BatchWriteItem)通过AppSync虚拟磁带库在AppSync上插入超过25个项目?

是否可以使用BatchPutItem (BatchWriteItem)通过AppSync虚拟磁带库在AppSync上插入超过25个项目?
EN

Stack Overflow用户
提问于 2019-11-18 13:38:01
回答 1查看 437关注 0票数 1

仅供参考:目前使用的是AppSync + React + Apollo,我正在尝试通过AppSync的Apache VTL发送38 - 40个项目进行更新。

我知道DynamoDB限制了插入到25 per request中的项目数量,但我认为AppSync没有这些限制。我想我错了,因为每当我发送超过25个项目(26+)时,我的请求都会失败。

下面是我的VTL脚本:

代码语言:javascript
复制
#set($isTenantValid = false)
#foreach($tenant in $context.identity.claims["https://app.schon.io/tenants"])
    #if($tenant == $ctx.args.tenantId)
        #set($isTenantValid = true)
    #end
#end

## Needs to verify if the employee has permission to insert students.

#if(!$isTenantValid) 
    $utils.unauthorized()
#end


#set($itemsToPut=[])
#set($pk="tenant:${ctx.args.tenantId}")
#set($userSK="tenant:${ctx.args.tenantId}:school-year:${ctx.args.schoolYear}")

#foreach($student in $ctx.args.students)
    #set($studentId = "${util.autoId()}")
    #set($sk="school-year:${ctx.args.schoolYear}:student:${studentId}")
    #set($userPK="student:${studentId}")

    #set($item = {
    "pk": $pk,
    "sk": $sk,
    "id": $studentId,
    "userPK": $userPK,
    "userSK": $userSK,
    "name": {
        "firstName" : $student.name.firstName,
        "lastName" : $student.name.lastName,
        "fullName": "${student.name.firstName} ${student.name.lastName}"
    },
    "schoolYear": $ctx.args.schoolYear,
    "createdAt": ${util.time.nowEpochSeconds()},
    "updatedAt": ${util.time.nowEpochSeconds()},
    "gender": $student.gender,
    "retired": $student.retired
    })
    #if("${student.diseases}" != "")
        $util.qr($item.add("diseases", $student.diseases)) 
    #end
    #if("${student.email}" != "")
        $util.qr($item.add("email", $student.email)) 
    #end
    #if("${student.birthdate}" != "")
        $util.qr($item.add("birthdate", $student.birthdate)) 
    #end

    $util.qr($itemsToPut.add($util.dynamodb.toMapValues($item)))
#end


{
    "version" : "2018-05-29",
    "operation" : "BatchPutItem",
    "tables" : {
        "SchonDB": $utils.toJson($itemsToPut)
    }
}

在这种情况下,我是否需要将其卸载到Lambda,并对每25个项目执行发送和重试逻辑?

EN

回答 1

Stack Overflow用户

发布于 2019-11-19 05:26:02

您是否可以尝试联系DDB团队,为您增加服务限制?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58908546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档