相关疑难解决方法(0)

1194
推荐指数
33
解决办法
102万
查看次数

AWS Dynamodb 文档客户端 UpdateCommand

AWS DynamoDB文档UpdateCommand中的 没有很好的记录并且难以使用。

我想使用 update 命令只获取一个 Javascript 对象,并将该对象中的所有键插入到与主键匹配的对象上。

看着InsertCommand我认为它会很简单,如下所示:

async updateItem(tableName: string, primaryKeyName: string, id: string, item: { [key: string]: any }) {
    const input: UpdateCommandInput = {
      Key: {
        [primaryKeyName]: id,
      },
      AttributeUpdates: item,
      TableName: tableName,
    };

    const command = new UpdateCommand(input);

    return await this.client.send(command);
  }
Run Code Online (Sandbox Code Playgroud)

但这似乎失败了。

amazon-web-services node.js amazon-dynamodb typescript

6
推荐指数
1
解决办法
8893
查看次数