File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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)
1519class 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
2228The classes provide some common use methods:
@@ -82,7 +88,7 @@ otherwise we wouldn't need one).
8288
8389Each Repository instance create an internal scoped session. The session gets
8490automatically 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
8793In this way we ensure the ` Session ` we use is isolated, and the same for all the operations we do with the
8894same Repository.
You can’t perform that action at this time.
0 commit comments