CSh*_*per 3 amazon-web-services node.js amazon-dynamodb typescript documentclient
我有一个简单的逻辑,我想INSERT使用 记录在表中AWS.DynamoDB.DocumentClient。下面是我正在使用的代码。在这里,我注意到.put正在更新记录,但不知道为什么。
在检查 CW 中的日志时,我没有看到任何错误,所以不确定我在这里错过了什么。
代码:
async addEvent(incomingModel: MyModel): Promise <MyModel> {
const dynamoModel: MyModel = {
fieldOne: incomingModel.fieldOne,
fieldTwo: incomingModel.fieldTwo,
"One#two#three": `${incomingModel.one}#${incomingModel.two}#${incomingModel.three}`,
fieldThree: incomingModel.fieldThree,
fieldFour: incomingModel.fieldFour,
};
var params = {
TableName: 'Table',
Item: dynamoModel,
};
return this.documentClient
.put(params)
.then((data) => {
this.logger.debug(
"Response received from Dynamo after adding an incomingModel",
data,
this.constructor.name,
);
return data as MyModel;
})
.catch((error) => {
const errorMessage = JSON.stringify(error);
this.logger.error(
`Error creating incomingModel with body of ${errorMessage}`,
error,
this.constructor.name,
);
throw error;
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4530 次 |
| 最近记录: |