From eb328d5e1e9cb600bc0b89e989a4d1bda6884586 Mon Sep 17 00:00:00 2001 From: mgjo5899 Date: Tue, 17 May 2022 01:10:35 -0700 Subject: [PATCH] adding more to decorator docs --- docs/connections_and_transactions.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/connections_and_transactions.md b/docs/connections_and_transactions.md index aa45537d..5ea74b97 100644 --- a/docs/connections_and_transactions.md +++ b/docs/connections_and_transactions.md @@ -95,6 +95,17 @@ async def create_users(request): ... ``` +When using with other decorators (such as route decorator `@router.post("")` +from FastAPI), try to put `@database.transaction()` right above the function +signature to ensure the automatic transaction management to be applied: + +```python +@router.post("/my-awesome-endpoint") +@database.transaction() +async def awesome_endpoint(): + ... +``` + Transaction blocks are managed as task-local state. Nested transactions are fully supported, and are implemented using database savepoints.