在DynamoDB Golang中删除不存在的身份

发布于 2025-02-05 20:03:13 字数 135 浏览 0 评论 0原文

我正在有一个Golang项目,其中我使用dynamodb作为我的后端数据库。当我们尝试删除不存在的实体时,我想返回错误。但是dynamodb.deleteitem不会在该内容上返回错误。请帮助我。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若沐 2025-02-12 20:03:14

您可以使用响应实际上从deleteitem方法中获得响应

前任:

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

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
    }
心碎的声音 2025-02-12 20:03:14

实际上,第一个结构由 deleteItem函数 deleteitemoutput

有一个评论,可以解决该对象的存在方式

仅在请求中指定为all_old时,此地图才出现在响应中。

您可以相应地调整逻辑,它可能会解决您的问题

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文