xn-model 1.0.0__tar.gz → 1.0.1__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.
- {xn_model-1.0.0/xn_model.egg-info → xn_model-1.0.1}/PKG-INFO +4 -3
- {xn_model-1.0.0 → xn_model-1.0.1}/pyproject.toml +2 -2
- {xn_model-1.0.0 → xn_model-1.0.1}/x_model/models.py +6 -3
- {xn_model-1.0.0 → xn_model-1.0.1/xn_model.egg-info}/PKG-INFO +4 -3
- {xn_model-1.0.0 → xn_model-1.0.1}/xn_model.egg-info/requires.txt +1 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/.env.sample +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/.gitignore +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/.pre-commit-config.yaml +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/README.md +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/makefile +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/setup.cfg +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/tests/__init__.py +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/tests/test_db.py +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/x_model/__init__.py +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/x_model/field.py +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/x_model/func.py +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/x_model/pydantic.py +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/xn_model.egg-info/SOURCES.txt +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/xn_model.egg-info/dependency_links.txt +0 -0
- {xn_model-1.0.0 → xn_model-1.0.1}/xn_model.egg-info/top_level.txt +0 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: xn-model
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Base model for xn-api
|
|
5
5
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/XyncNet/x-model
|
|
8
8
|
Project-URL: Repository, https://github.com/XyncNet/x-model
|
|
9
9
|
Keywords: tortoise,model,crud,generator,api,admin
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: tortoise-orm[accel,asyncpg]
|
|
13
|
+
Requires-Dist: fastapi
|
|
13
14
|
Provides-Extra: dev
|
|
14
15
|
Requires-Dist: pytest; extra == "dev"
|
|
15
16
|
Requires-Dist: python-dotenv; extra == "dev"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "xn-model"
|
|
3
|
-
requires-python = ">=3.
|
|
3
|
+
requires-python = ">=3.11"
|
|
4
4
|
authors = [
|
|
5
5
|
{name = "Mike Artemiev", email = "mixartemev@gmail.com"},
|
|
6
6
|
]
|
|
7
|
-
dependencies = ['tortoise-orm[accel,asyncpg]']
|
|
7
|
+
dependencies = ['tortoise-orm[accel,asyncpg]', 'fastapi']
|
|
8
8
|
keywords = ["tortoise", "model", "crud", "generator", "api", "admin"]
|
|
9
9
|
description = 'Base model for xn-api'
|
|
10
10
|
readme = "README.md"
|
|
@@ -5,6 +5,8 @@ from tortoise import Model as BaseModel
|
|
|
5
5
|
from tortoise.contrib.pydantic import pydantic_model_creator, PydanticModel
|
|
6
6
|
from tortoise.fields import DatetimeField, IntField
|
|
7
7
|
|
|
8
|
+
from x_model import HTTPException, FailReason
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
class DatetimeSecField(DatetimeField):
|
|
10
12
|
class _db_postgres:
|
|
@@ -39,9 +41,10 @@ class Model(BaseModel):
|
|
|
39
41
|
|
|
40
42
|
# # # CRUD Methods # # #
|
|
41
43
|
@classmethod
|
|
42
|
-
async def
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
async def get_one(cls, id_: int, **filters) -> PydanticModel:
|
|
45
|
+
if obj := await cls.get_or_none(id=id_, **filters):
|
|
46
|
+
return await cls.pyd().from_tortoise_orm(obj)
|
|
47
|
+
raise HTTPException(reason=FailReason.path, status_=404, parent=f"{cls.__name__}#{id_} not found")
|
|
45
48
|
|
|
46
49
|
@classmethod
|
|
47
50
|
async def get_or_create_by_name(cls, name: str, attr_name: str = None, def_dict: dict = None) -> "Model":
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: xn-model
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Base model for xn-api
|
|
5
5
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/XyncNet/x-model
|
|
8
8
|
Project-URL: Repository, https://github.com/XyncNet/x-model
|
|
9
9
|
Keywords: tortoise,model,crud,generator,api,admin
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: tortoise-orm[accel,asyncpg]
|
|
13
|
+
Requires-Dist: fastapi
|
|
13
14
|
Provides-Extra: dev
|
|
14
15
|
Requires-Dist: pytest; extra == "dev"
|
|
15
16
|
Requires-Dist: python-dotenv; extra == "dev"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|