24 ms·
Understanding and Preventing Race Conditions in Web Applications
- tony-allan 2y agoA mistake that I have made! And the answer is: UPDATE TABLE posts SET views = views + 1 WHERE post_id = $1 RETURNING views; @app.post("/view/{post_id}") async def view_post(post_id: int): await Post.filter(id=post_id).update(views=F("views") + 1) post = await Post.filter(id=post_id).get() return {"current_views": post.views}