dynalite
dynalite copied to clipboard
support for Dynamo Feature: ReturnValuesOnConditionCheckFailure
Hi,
Can you add support of ReturnValuesOnConditionCheckFailure parameters in putItem,updateItem,batchWriteItem ...
https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ConditionCheck.html
When the API thrown an error with code = 'ConditionalCheckFailedException' Then the err include an "Item" containing the document in the db:
const cli = new AWS.DynamoDB({region:'local', endpoint: process.env.MOCK_DYNAMODB_ENDPOINT})
try {
await cli.putItem({TableName: 'X', Item: {_id:{S:'test'}, v:{N:"1"}}}).promise()
await cli.putItem({TableName: 'X', Item: {_id:{S:'test'}, v:{N:"3"}}
ReturnValuesOnConditionCheckFailure: 'OLD_OLD',
ExpressionAttributeNames: {'#V' : 'v'},
ConditionExpression: '#V = :V',
ExpressionAttributeValues: {':V':{N:"2}}
}).promise()
} catch (err) {
console.debug(err.code, err.Item)
// Item = { _id : {S: "test"}, v: {N: "1}}
}
It works when I use the real dynamodb directly, and failed with this module or the dynamodb local provided by amazon. this feature were release in july this year.
Thanks
As of December 14, 2023, DynamoDB Local supports this feature. Can it be supported here, too? https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html