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.