xn-model 1.0.5__tar.gz → 1.0.6__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: xn-model
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
@@ -45,6 +45,13 @@ class Model(TrtModel):
45
45
  )
46
46
  return cls._pydIn
47
47
 
48
+ # # # CRUD Methods # # #
49
+ @classmethod
50
+ async def get_one(cls, id_: int) -> PydanticModel:
51
+ if obj := await cls.get_or_none(id=id_):
52
+ return await cls.pyd().from_tortoise_orm(obj)
53
+ raise LookupError(f"{cls.__name__}#{id_} not found")
54
+
48
55
  async def one(self) -> PydanticModel:
49
56
  return await self.pyd().from_tortoise_orm(self)
50
57
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: xn-model
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes