internal 1.1.35__py3-none-any.whl → 1.1.35.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.
Potentially problematic release.
This version of internal might be problematic. Click here for more details.
internal/model/base_model.py
CHANGED
|
@@ -27,8 +27,8 @@ class InternalBaseDocument(Document):
|
|
|
27
27
|
@classmethod
|
|
28
28
|
async def get_pagination_list(cls, app: FastAPI, query: list = None, sort: List[Tuple] = None,
|
|
29
29
|
page_size: int = DEF_PAGE_SIZE, page_no: int = DEF_PAGE_NO,
|
|
30
|
-
ignore_cache: bool = False,
|
|
31
|
-
|
|
30
|
+
ignore_cache: bool = False, fetch_links: bool = False,
|
|
31
|
+
exclude_fields: List[str] = None):
|
|
32
32
|
if not query:
|
|
33
33
|
final_query = []
|
|
34
34
|
else:
|
|
@@ -59,8 +59,15 @@ class InternalBaseDocument(Document):
|
|
|
59
59
|
else:
|
|
60
60
|
page_no = max(1, min(page_no, total_pages))
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
# 建立查詢物件用於取得分頁資料
|
|
63
|
+
data_query = cls.find(*final_query, ignore_cache=ignore_cache, fetch_links=fetch_links)
|
|
64
|
+
|
|
65
|
+
# 如果有指定要排除的欄位,使用 project() 方法
|
|
66
|
+
if exclude_fields:
|
|
67
|
+
projection = {field: 0 for field in exclude_fields}
|
|
68
|
+
data_query = data_query.project(projection)
|
|
69
|
+
|
|
70
|
+
page_data = await data_query.sort(*final_sort).limit(page_size).skip((page_no - 1) * page_size).to_list()
|
|
64
71
|
|
|
65
72
|
return page_no, page_size, total_num, page_data
|
|
66
73
|
|
|
@@ -89,7 +96,7 @@ class InternalBaseDocument(Document):
|
|
|
89
96
|
|
|
90
97
|
@classmethod
|
|
91
98
|
async def get_list(cls, app: FastAPI, query: list = None, sort: List[Tuple] = None, ignore_cache: bool = False,
|
|
92
|
-
fetch_links: bool = False):
|
|
99
|
+
fetch_links: bool = False, exclude_fields: List[str] = None):
|
|
93
100
|
if not query:
|
|
94
101
|
final_query = []
|
|
95
102
|
else:
|
|
@@ -109,9 +116,15 @@ class InternalBaseDocument(Document):
|
|
|
109
116
|
continue
|
|
110
117
|
final_sort.append((cls.id, pymongo.ASCENDING))
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
# 建立查詢物件
|
|
120
|
+
query_obj = cls.find(*final_query, ignore_cache=ignore_cache, fetch_links=fetch_links)
|
|
121
|
+
|
|
122
|
+
# 如果有指定要排除的欄位,使用 project() 方法
|
|
123
|
+
if exclude_fields:
|
|
124
|
+
projection = {field: 0 for field in exclude_fields}
|
|
125
|
+
query_obj = query_obj.project(projection)
|
|
114
126
|
|
|
127
|
+
data = await query_obj.sort(*final_sort).to_list()
|
|
115
128
|
return data
|
|
116
129
|
|
|
117
130
|
def model_dump(
|
|
@@ -31,10 +31,10 @@ internal/interface/base_interface.py,sha256=3YaVjIgLi_pZpLk5SEIk8WVkuICM8qPavT8r
|
|
|
31
31
|
internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
32
|
internal/middleware/log_request.py,sha256=OFwWnGfzXnllcQsBHolAWVsahXKoEhw3OQ1YWOm7RHM,2087
|
|
33
33
|
internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
internal/model/base_model.py,sha256=
|
|
34
|
+
internal/model/base_model.py,sha256=fgqdGrtPLyqAtQU8RQb9hLxvarDuubFgv2uEFczmBbw,6150
|
|
35
35
|
internal/model/operate.py,sha256=QSM6yXYXpJMwrqkUGEWZLrEBaUgqHwVHY_Fi4S42hKc,3190
|
|
36
36
|
internal/utils.py,sha256=wK1QumW1AaWE1ga2-WcDH2rtXRr2hSLwXzy-iI5dTzY,3962
|
|
37
37
|
internal/validator_utils.py,sha256=CqjaVFoAu5MqvBG_AkTP-r7AliWawtUWB851USj4moI,1519
|
|
38
|
-
internal-1.1.35.dist-info/METADATA,sha256
|
|
39
|
-
internal-1.1.35.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
40
|
-
internal-1.1.35.dist-info/RECORD,,
|
|
38
|
+
internal-1.1.35.2.dist-info/METADATA,sha256=-wMPKHaGDzPkf7fUi2xXlyUmDTZQK7BeYFSVusCevYQ,941
|
|
39
|
+
internal-1.1.35.2.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
40
|
+
internal-1.1.35.2.dist-info/RECORD,,
|
|
File without changes
|