TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Understanding and Preventing Race Conditions in Web Applications

4 点作者 Tiberium8 个月前

1 comment

tony-allan8 个月前
A mistake that I have made!<p>And the answer is:<p><pre><code> UPDATE TABLE posts SET views = views + 1 WHERE post_id = $1 RETURNING views; @app.post(&quot;&#x2F;view&#x2F;{post_id}&quot;) async def view_post(post_id: int): await Post.filter(id=post_id).update(views=F(&quot;views&quot;) + 1) post = await Post.filter(id=post_id).get() return {&quot;current_views&quot;: post.views}</code></pre>