SARepo 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- SARepo/repo.py +2 -1
- SARepo/sa_repo.py +15 -1
- {sarepo-0.1.0.dist-info → sarepo-0.1.2.dist-info}/METADATA +1 -1
- sarepo-0.1.2.dist-info/RECORD +12 -0
- sarepo-0.1.0.dist-info/RECORD +0 -12
- {sarepo-0.1.0.dist-info → sarepo-0.1.2.dist-info}/WHEEL +0 -0
- {sarepo-0.1.0.dist-info → sarepo-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {sarepo-0.1.0.dist-info → sarepo-0.1.2.dist-info}/top_level.txt +0 -0
SARepo/repo.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
|
2
|
-
from typing import Generic, TypeVar, Type, Optional, Any, Protocol
|
2
|
+
from typing import Generic, List, TypeVar, Type, Optional, Any, Protocol
|
3
3
|
from .base import Page, PageRequest
|
4
4
|
|
5
5
|
T = TypeVar("T")
|
6
6
|
|
7
7
|
class CrudRepository(Protocol, Generic[T]):
|
8
8
|
model: Type[T]
|
9
|
+
def getAll(self, limit: Optional[int]) -> List[T]: ...
|
9
10
|
def get(self, id_: Any) -> T: ...
|
10
11
|
def try_get(self, id_: Any) -> Optional[T]: ...
|
11
12
|
def add(self, entity: T) -> T: ...
|
SARepo/sa_repo.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
from typing import Type, Generic, TypeVar, Optional, Sequence, Any, Callable
|
2
|
+
from typing import List, Type, Generic, TypeVar, Optional, Sequence, Any, Callable
|
3
3
|
from sqlalchemy.orm import Session
|
4
4
|
from sqlalchemy.ext.asyncio import AsyncSession
|
5
5
|
from sqlalchemy import select, func
|
@@ -17,6 +17,13 @@ class SARepository(Generic[T]):
|
|
17
17
|
def _select(self):
|
18
18
|
return select(self.model)
|
19
19
|
|
20
|
+
def getAll(self, limit: Optional[int] = None) -> List[T]:
|
21
|
+
stmt = select(self.model)
|
22
|
+
if limit is not None:
|
23
|
+
stmt = stmt.limit(limit)
|
24
|
+
result = self.session.execute(stmt)
|
25
|
+
return result.scalars().all()
|
26
|
+
|
20
27
|
def get(self, id_: Any) -> T:
|
21
28
|
obj = self.session.get(self.model, id_)
|
22
29
|
if not obj:
|
@@ -62,6 +69,13 @@ class SAAsyncRepository(Generic[T]):
|
|
62
69
|
def __init__(self, model: Type[T], session: AsyncSession):
|
63
70
|
self.model = model
|
64
71
|
self.session = session
|
72
|
+
|
73
|
+
async def getAll(self, limit: Optional[int] = None) -> List[T]:
|
74
|
+
stmt = select(self.model)
|
75
|
+
if limit is not None:
|
76
|
+
stmt = stmt.limit(limit)
|
77
|
+
result = await self.session.execute(stmt)
|
78
|
+
return result.scalars().all()
|
65
79
|
|
66
80
|
def _select(self):
|
67
81
|
return select(self.model)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
SARepo/__init__.py,sha256=tNYbuUDloC1qVnXq7uomS3jRcaPUvy0VEZiMdYR6x1M,183
|
2
|
+
SARepo/base.py,sha256=UbAdZ9WYh_o93mrCVL3D8Q0tY_8mvm0HspO_L5m0GTQ,874
|
3
|
+
SARepo/models.py,sha256=ypSmbKAijvNH4WjSeJBgyNT8mKa_e_7-I5kiNisjGAI,570
|
4
|
+
SARepo/repo.py,sha256=QJ_8VHxnGyHIyfjEMyw8-70k9Qhv4VUjQwSN9LnJCC8,547
|
5
|
+
SARepo/sa_repo.py,sha256=P3V1fa8C3beERdGvcBAtDd1psDwpoxxx9r-om2ZwhMk,4139
|
6
|
+
SARepo/specs.py,sha256=e-X1cCkva3e71M37hcfbjNDMezZAaOkkRaPToUzhEeU,687
|
7
|
+
SARepo/uow.py,sha256=yPlvi7PoH9x2pLNt6hEin9zT5qG9axUKn_TkZcIuz1s,859
|
8
|
+
sarepo-0.1.2.dist-info/licenses/LICENSE,sha256=px90NOQCrnZ77qoFT8IvAiNS1CXQ2OU27uVBKbki9DM,131
|
9
|
+
sarepo-0.1.2.dist-info/METADATA,sha256=Ff0HK8YEwHHvZN1Lpg-VwOTvFX0H-jWJk-vpZk0TYIo,2691
|
10
|
+
sarepo-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
sarepo-0.1.2.dist-info/top_level.txt,sha256=0k952UYVZLIIv3kZzFlxI0yzBMusZo3-XCQtxms_kS0,7
|
12
|
+
sarepo-0.1.2.dist-info/RECORD,,
|
sarepo-0.1.0.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
SARepo/__init__.py,sha256=tNYbuUDloC1qVnXq7uomS3jRcaPUvy0VEZiMdYR6x1M,183
|
2
|
-
SARepo/base.py,sha256=UbAdZ9WYh_o93mrCVL3D8Q0tY_8mvm0HspO_L5m0GTQ,874
|
3
|
-
SARepo/models.py,sha256=ypSmbKAijvNH4WjSeJBgyNT8mKa_e_7-I5kiNisjGAI,570
|
4
|
-
SARepo/repo.py,sha256=vCVQmjYifzlO_ggOFwj3Xdyqt4_7ILDoUtHUAFnFyZU,482
|
5
|
-
SARepo/sa_repo.py,sha256=mdTe3RyrGklG3z50jr4pOv4aidWxOZ_6dtdLgr83Osk,3617
|
6
|
-
SARepo/specs.py,sha256=e-X1cCkva3e71M37hcfbjNDMezZAaOkkRaPToUzhEeU,687
|
7
|
-
SARepo/uow.py,sha256=yPlvi7PoH9x2pLNt6hEin9zT5qG9axUKn_TkZcIuz1s,859
|
8
|
-
sarepo-0.1.0.dist-info/licenses/LICENSE,sha256=px90NOQCrnZ77qoFT8IvAiNS1CXQ2OU27uVBKbki9DM,131
|
9
|
-
sarepo-0.1.0.dist-info/METADATA,sha256=lHz7KBK2U2CAvoxwUB1ytK9d1LeNoiV0ODlvM7BFjgE,2691
|
10
|
-
sarepo-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
-
sarepo-0.1.0.dist-info/top_level.txt,sha256=0k952UYVZLIIv3kZzFlxI0yzBMusZo3-XCQtxms_kS0,7
|
12
|
-
sarepo-0.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|