node.js - 如何使用 TypeScript 定义 DynamoDB get 的返回类型?

标签 node.js typescript amazon-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)

最佳答案

如果您检查the definition of GetItemOutputthe definition of PromiseResult您将看到 Promise 返回一个 {Item, ConsumedCapacity, $response} 的对象,但不仅仅是结果。因此,我认为您应该使用 PromiseResult 作为类型,并使用 Item 属性作为结果。

关于node.js - 如何使用 TypeScript 定义 DynamoDB get 的返回类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62285490/

相关文章:

node.js - Mongoose - 如何为所有模型创建通用方法?

css - 包括在 Webpack 生产中不起作用的 node_modules css 文件

java - Amazon DynamoDB 映射枚举

typescript - 如何使用 VSCode api 打开自定义编辑器

javascript - Kotlin 喜欢 JavaScript 中的作用域函数(让、也、应用、运行)?

python - 更改 dynamoDB 中列类型的最佳方法

javascript - AWS DynamoDB 未返回对 Lambda 函数的响应

node.js - 如何迭代属于该教室的学生列表?

node.js - 如何替换文件(或多个文件)中的多行?

node.js - 如何在 typescript 中获得与express的Post方法相同的数据类型