Skip to content

support for Dynamo Feature: ReturnValuesOnConditionCheckFailure #182

@vincent-ogury

Description

@vincent-ogury

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions