typescript - DynamoDB 客户端错误 - TypeError: n.transactWrite 不是函数\n
问题描述
我正在尝试使用节点 sdk 中的 DynamoDB transactWrite 函数(https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#transactWrite-property)
对于 API Gateway 触发的我的 lambda 函数,该函数按预期工作,但对于我的 DynamoDB Stream 事件调用的 lambda 函数,我收到以下错误。
TypeError: n.transactWrite is not a function\n
所有 Lambda 函数都在 10.X 运行时。
下面是一个示例,说明我如何使用虚拟数据调用函数以进行说明。
import { DynamoDB } from 'aws-sdk'
const dynamoDb: DynamoDB.DocumentClient = new DynamoDB.DocumentClient({})
const request: DynamoDB.DocumentClient.TransactWriteItemsInput = {
TransactItems: [{
Update: {
TableName: "example",
Key: {
partitionKey: "someid",
sortKey: "somesortkey",
},
UpdateExpression: 'set gsi1sk = :gsi1sk',
ExpressionAttributeValues: {
':gsi1sk': "somenewvalue"
},
},
}]
}
dynamoDb.transactWrite(request)
DynamoDB 调用的 lambda 函数是否有减少的功能集?还是使用旧版本的 SDK 之类的?
解决方案
尝试使用
var dynamodb = 新 aws.DynamoDB();
代替
var dynamodb = 新 aws.DynamoDB.DocumentClient();
推荐阅读
- reactjs - 使用反应钩子将道具从组件传递到组件
- css - 雅虎邮箱 CSS 目标 2020
- javascript - Firebase 实时数据库获取父节点值 .val()
- macos - 使用键盘快捷键为电子邮件运行 AppleScript
- python - 使用模板通过电子邮件请求文档签名不会填充选项卡值
- android - 如何在 Kotlin 中检查等价物
- sql-server - 除非使用 exec('...'),否则开始 try/catch 不会在不存在的表上捕获 select?
- wordpress - 跟踪插件冲突 WordPress(CiviCRM / 事件管理器)
- python - 有没有办法搜索特定的在使用 Python 和 BeautifulSoup 的 HTML 注释中
- node.js - 猫鼬连接的选项