Home > Blockchain >  Deleting a non-existing identity in DynamoDB Golang
Deleting a non-existing identity in DynamoDB Golang

Time:06-09

I am having a golang project where I am using dynamoDB as my backend database. I wanted to return the error when we are trying to Delete a non-existing entity. But the DynamoDB.DeleteItem does not return an error on that thing. Please help me with that.

CodePudding user response:

You can actually do it using the response you will get from DeleteItem method in dynamoDB.

Ex:

resp, err := dynamoDB.DeleteItem(input)
    if resp.ConsumedCapacity != nil {
        \\entity not found error
    }

CodePudding user response:

Actually, the first struct returned by the DeleteItem function is a DeleteItemOutput

There's a comment that addresses how this object would be present

This map appears in the response only if ReturnValues was specified as ALL_OLD in the request.

You can adjust your logic accordingly and it might solve your problem

  • Related