基于其他字段的DynamoDB更新

发布于 2025-01-25 05:55:54 字数 497 浏览 3 评论 0原文

目前,我有一个帖子表,该表存储喜欢 puntriity ,我基本上想更改 Puntriity puminity 字段,取决于此喜欢字段,例如:

if (likes > 100) popularity = 3
else if (likes > 50) popularity = 2
else if (likes > 10) popularity = 1
else popularity = 0

PURINTIOS(0)意味着该帖子是新的,而受欢迎程度(3)帖子是用户在探索页面上看到的最多的帖子。

现在,我需要获取每篇文章以获取他们的总喜欢,然后致电其 Pumority 的更新。有没有办法在一个单个更新功能中执行此操作,而无需事先获取帖子?

Currently I have a posts table which stores likes and popularity, basically I want to change the popularity field depending on this likes field, such as:

if (likes > 100) popularity = 3
else if (likes > 50) popularity = 2
else if (likes > 10) popularity = 1
else popularity = 0

Popularity(0) means the post is new, whereas popularity(3) posts are the ones users see the most on their explore page.

Right now I need to fetch each post to get their total likes and then call an update for its popularity. Is there a way to do this in one single update function without fetching the post beforehand?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文