Skip to content

Commit 85753e0

Browse files
committed
Documentation update
1 parent 1dc0c67 commit 85753e0

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ to check [SQLAlchemy asyncio documentation](https://docs.sqlalchemy.org/en/20/or
189189

190190
## Repository / Unit of work
191191

192-
The `SQLAlchemyRepository` and `SQLAlchemyAsyncRepository` class can be used simply by extending them.
192+
The `SQLAlchemyRepository` and `SQLAlchemyAsyncRepository` class can be used directly or by extending them.
193193

194194
```python
195195
from sqlalchemy_bind_manager.repository import SQLAlchemyRepository
@@ -198,12 +198,17 @@ from sqlalchemy_bind_manager.repository import SQLAlchemyRepository
198198
class MyModel(model_declarative_base):
199199
pass
200200

201+
# Direct usage
202+
repo_instance = SQLAlchemyRepository(sqlalchemy_bind_manager.get_bind(), model_class=MyModel)
201203

202204
class ModelRepository(SQLAlchemyRepository[MyModel]):
203205
_model = MyModel
206+
207+
def _some_custom_method_implemented(self):
208+
...
204209

205-
206-
repo_instance = ModelRepository(sqlalchemy_bind_manager.get_bind())
210+
# Extended class usage
211+
extended_repo_instance = ModelRepository(sqlalchemy_bind_manager.get_bind())
207212
```
208213

209214
The classes provide some common use methods:
@@ -253,7 +258,6 @@ approach for multiple operations.
253258

254259
We can use the `UnitOfWork` or the `AsyncUnitOfWork` class to provide a shared session to
255260
be used for repository operations, **assumed the same bind is used for all the repositories**.
256-
(Two phase transactions are not currently supported).
257261

258262
```python
259263
class MyRepo(SQLAlchemyRepository):

docs/index.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ with sa_manager.get_session() as session:
7575
session.commit()
7676
```
7777

78-
??? warning "Long lived sessions and multithreading"
79-
It's not recommended to create long-lived sessions like:
80-
81-
```
82-
session = sa_manager.get_session()
83-
```
84-
85-
This can create problems because of global variables and multi-threading.
86-
More details can be found in the [session page](/manager/session/#note-on-multithreaded-applications)
87-
78+
/// details | Long lived sessions and multithreading
79+
type: warning
80+
81+
It's not recommended to create long-lived sessions like:
82+
83+
```
84+
session = sa_manager.get_session()
85+
```
86+
87+
This can create unexpected because of global variables and multi-threading.
88+
More details can be found in the [session page](/manager/session/#note-on-multithreaded-applications)
89+
///

docs/manager/models.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Or using the imperative approach:
2020
```python
2121
from dataclasses import dataclass
2222
from sqlalchemy import Integer, String, Table, Column
23+
2324
@dataclass
2425
class MyModel:
2526
id: int

docs/repository/repository.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
## Repository / Unit of work
22

3-
The `SQLAlchemyRepository` and `SQLAlchemyAsyncRepository` class can be used simply by extending them.
3+
The `SQLAlchemyRepository` and `SQLAlchemyAsyncRepository` class can be used directly or by extending them.
44

55
```python
66
from sqlalchemy_bind_manager.repository import SQLAlchemyRepository
77

88

9-
class MyModel(model_declarative_base_from_sa_manager_bind):
9+
class MyModel(model_declarative_base):
1010
pass
1111

12+
# Direct usage
13+
repo_instance = SQLAlchemyRepository(sqlalchemy_bind_manager.get_bind(), model_class=MyModel)
1214

1315
class ModelRepository(SQLAlchemyRepository[MyModel]):
1416
_model = MyModel
15-
16-
17-
repo_instance = ModelRepository(sqlalchemy_bind_manager.get_bind())
17+
18+
def _some_custom_method_implemented(self):
19+
...
1820
```
1921

2022
The classes provide some common use methods:

docs/repository/uow.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ repository provide by itself an isolated session for single operations, we have
55
approach for multiple operations.
66

77
We can use the `UnitOfWork` or the `AsyncUnitOfWork` class to provide a shared session to
8-
be used for repository operations, **assumed the same bind is used for all the repositories**.
9-
(Two phase transactions are not currently supported).
8+
be used for repository operations, **assuming the same bind is used for all the repositories**.
9+
10+
/// admonition | The direct use of `SQLAlchemyRepository` and `SQLAlchemyAsyncRepository` classes is not yet supported
11+
type: warning
12+
///
1013

1114
```python
1215
class MyRepo(SQLAlchemyRepository):

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ nav:
2121
- Unit of work: repository/uow.md
2222

2323
markdown_extensions:
24-
- pymdownx.snippets
2524
- pymdownx.details
25+
- pymdownx.blocks.admonition
26+
- pymdownx.blocks.details

0 commit comments

Comments
 (0)