Skip to content

Commit 2e6bc11

Browse files
authored
Merge pull request #41 from febus982/update_repository_usage_docs
Update repository usage docs
2 parents ea2b9cc + 11c77ee commit 2e6bc11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/repository/usage.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ class MyModel(model_declarative_base):
1010
pass
1111

1212
# Direct usage
13-
repo_instance = SQLAlchemyRepository(sqlalchemy_bind_manager.get_bind(), model_class=MyModel)
13+
repo_instance = SQLAlchemyRepository(
14+
sa_manager.get_bind(),
15+
model_class=MyModel
16+
)
1417

18+
# Child class usage (when you need to implement custom repository methods)
1519
class ModelRepository(SQLAlchemyRepository[MyModel]):
1620
_model = MyModel
1721

1822
def _some_custom_method_implemented(self):
1923
...
24+
25+
repo_instance_2 = ModelRepository(sa_manager.get_bind())
2026
```
2127

2228
The classes provide some common use methods:
@@ -82,7 +88,7 @@ otherwise we wouldn't need one).
8288

8389
Each Repository instance create an internal scoped session. The session gets
8490
automatically closed when the Repository instance is not referenced by any variable (and the
85-
garbage collector clean it up)
91+
garbage collector cleans it up)
8692

8793
In this way we ensure the `Session` we use is isolated, and the same for all the operations we do with the
8894
same Repository.

0 commit comments

Comments
 (0)