node.js - 如何使用 TypeScript 为 DynamoDB 定义返回类型?
问题描述
我有:
let resItem: Schema
resItem = await dynamoClient.get({
TableName,
Key: {
uuid: request.body.uuid
}
}).promise()
但我得到:
Type 'PromiseResult<GetItemOutput, AWSError>' is missing the following properties from type 'Schema': uuid, topics, phoneNumber, timezonets(2739)
解决方案
如果您检查GetItemOutput 的定义和 PromiseResult的定义,您将看到 promise 正在返回一个对象,{Item, ConsumedCapacity, $response}
但不仅仅是结果。所以我认为你应该使用PromiseResult
作为类型并使用Item
属性作为你的结果。
推荐阅读
- makefile - 连续运行 Makefile 会出现“No rule to make target”错误
- c - C 新手——我在这里做一些不安全的事情吗?
- wordpress - 将 woocommerce 产品排序添加到自定义订单 + 价格
- python - 尝试运行名为 PspNet 的 Keras 分割模型时出现“NameError: name 'np' is not defined”
- ios - 使用偏移时导航栏项目可点击区域切割
- tfs - 如何为 TFS 中创建的每个新功能自动创建用户故事
- php - 将 HTML 附加到 PHP 字符串
- javascript - 来自 API 数据的 for 循环中的 if 语句
- .net-core - F# FSI 和 .Net 核心。找不到正确的 System.Runtime.dll
- node.js - 类型“未知 []”缺少类型“[字符串,未知]”的以下属性:0、1ts(2739)