SQL在DynamoDB中触发替代方案

发布于 2025-02-02 18:21:40 字数 139 浏览 3 评论 0原文

我在一个移动窗口的表中有一个列表属性。我希望在DynamoDB中创建一个触发器,以便每当将某些内容附加到列表上时,它会移动一个,从而降低最早的值。如果我使用的是SQL,Create Trigger将是我的去处,但是DynamoDB呢?

I have a list attribute in a table which is a moving window. I wish to create a trigger in DynamoDb such that whenever something is appended to the list it shifts by one, dropping the earliest value. If I were using SQL, create trigger would've been my go to, but what about DynamoDb?

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

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

发布评论

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

评论(2

紫﹏色ふ单纯 2025-02-09 18:21:40

AWS将其称为此文档 。基本上,您编写一个lambda功能来完成您想要的事情。但是,在您的示例中,您必须小心,不要在更新DynamoDB的情况下创建一个无限的循环,调用lambda并更新DynamoDB,然后再次调用您的lambda。但是 A>实际上将此设计模式称为数据库触发器。

AWS refers to it as a trigger in this document. Basically you write a Lambda function to do what you want. However, in your example you would have to be careful not to create an infinite loop where DynamoDB is updated, Lambda is called and updates DynamoDB and then your Lambda is called again. But this post actually calls this design pattern a database trigger.

去了角落 2025-02-09 18:21:40

Dynamo DB没有SQL的“更新之前”触发器。

DDB的流功能经常被引用并像“后更新”触发器一样使用...根本不像真正的RDMS SQL触发器那样。

如果您确实必须使用DDB,那么您会与自己所需逻辑的API一起使用DDB。

我想正如另一个答案所建议的那样,您可以仔细实现DDB“触发” lambda。但是,请意识到您将为每次更新而不是仅1付费2写信。此外,假设您希望列出最新的10个项目。您的应用程序有时必须准备好看到11,12或13。由于“触发器”是与实际DB写入的异步。

Dynamo DB doesn't have anything like SQL's "Before Update" trigger.

DDB's Stream functionality, while often referred to and used like an "After Update" trigger...isn't really at all like a real RDMS SQL trigger.

If you really must use DDB, then you're stuck with fronting DDB with your own API that implements the logic you require.

I suppose as suggested by another answer you might carefully implement a DDB "trigger" lambda. But realize you're going to pay for 2 writes for every update instead of just 1. In addition, let say you want you list to have the most recent 10 items. Your apps would have to be prepared to see 11, or 12, or 13 sometimes. Since the the "trigger" is async from the actual DB writes.

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