Я хочу вставить новый элемент в таблицу, только если определенный элемент уже существует. Можно ли добиться этого с помощью transact_write_items? Я хочу избежать запроса таблицы, а затем вставки нового элемента.
response = dynamo_client.transact_write_items(
TransactItems=[
{
'ConditionCheck': {
'Key': {
'indicator_id': {
'S': 'indicator_1'
}
},
'ConditionExpression': 'attribute_exists(#indicator_id)',
'ExpressionAttributeNames': {
'#indicator_id': 'indicator_id'
},
'TableName': 'CAS'
},
'Put': {
'Key': {
'indicator_id': {
'S': 'update_indicator_1'
}
},
'TableName': 'CAS'
}
}
]
)
Это вызывает следующую ошибку:
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the TransactWriteItems operation: TransactItems can only contain one of Check, Put, Update or Delete