【发布时间】:2020-09-29 04:07:06
【问题描述】:
我有这张 DynamoDB 表
TableName: MyTable
string HashKey: Id,
string RangeKey: createTime
Other attributes
string partId
string carNum
string partId_carNum
Local_secondary_index : partId, projection_type = "ALL"
Local_secondary_index : partId_carNum, projection_type = "ALL"
我正在尝试使用 Id 和 partId_carNum 的独特组合来实现发布。但是条件表达式不起作用。我在表中看到重复的条目。我的代码有什么问题?
这是我的 typeScript 的样子
下面是一个项目的例子
{
"Id" : "000001823841",
"partId" : "1",
"carNum" : "car",
"createTime" : "124232353"
}
const params: PutItemInput = {
TableName: MyTable,
Item: item,
ConditionExpression: 'Id <> :f AND partId_carNum <> :g',
ExpressionAttributeValues: {
':f': { 'S': '000001823841' },
':g': { 'S': '1#car' }
}
};
return await new DynamoDB()
.putItem(params)
.promise()
.then(() => {
console.log(`SUCCESS: Event with ID inserted`);
})
.catch(err => {
console.error(`FAILED to write event to ${params.TableName}. with Error: ${err}`);
});
【问题讨论】:
标签: node.js amazon-web-services amazon-dynamodb