1
- import re , os , json , tempfile , logging , sys , asyncio , jwt , difflib , importlib , platform
1
+ import re , os , json , tempfile , logging , sys
2
+ import asyncio , jwt , difflib , importlib , platform
2
3
from datetime import datetime , timedelta
3
4
from contextlib import contextmanager
4
5
from functools import lru_cache
119
120
UserRelationshipModel ,
120
121
FormConfigUpdateRequest ,
121
122
SiteConfig ,
122
- FileUpload ,
123
123
get_user_model ,
124
124
get_form_model ,
125
125
get_form_names ,
@@ -1080,6 +1080,7 @@ async def api_form_read_all(
1080
1080
set_length : int = 0 ,
1081
1081
newest_first : bool = False ,
1082
1082
return_when_empty : bool = False ,
1083
+ query_params : Optional [str ] = Query (None ),
1083
1084
):
1084
1085
"""
1085
1086
Retrieves all documents of a specified form type, identified by the form name in the URL.
@@ -1095,7 +1096,10 @@ async def api_form_read_all(
1095
1096
the results. This applies to the created_at field, you can pair this option with the
1096
1097
sort_by_last_edited=True param to get the most recently modified forms at the top. If
1097
1098
you want the endpoint to return empty lists instead of raising an error, then pass
1098
- return_when_empty=true.
1099
+ return_when_empty=true. You can pass query_params as a url-encoded dict to filter
1100
+ data using the ==, !=, >, >=, <, <=, in, and nin operators. Example usage of this param:
1101
+ {"data":{"age": {"operator": ">=", "value": 21},"name": {"operator": "==","value": "John"}}}.
1102
+ '{"data": {"Fiscal_Year": {"condition": ">", "value": 2024}}}'
1099
1103
"""
1100
1104
1101
1105
if form_name not in get_form_names (config_path = config .FORM_CONFIG_PATH ):
@@ -1119,6 +1123,15 @@ async def api_form_read_all(
1119
1123
except Exception as e :
1120
1124
limit_query_to = user .username
1121
1125
1126
+ print ("\n \n \n " ,query_params )
1127
+
1128
+ # Decode the JSON string to a dictionary
1129
+ if query_params :
1130
+ try :
1131
+ query_params = json .loads (query_params )
1132
+ except json .JSONDecodeError :
1133
+ raise HTTPException (status_code = 400 , detail = "Invalid query_params format. Must be a JSON string." )
1134
+
1122
1135
documents = doc_db .get_all_documents (
1123
1136
form_name = form_name ,
1124
1137
limit_users = limit_query_to ,
@@ -1128,6 +1141,7 @@ async def api_form_read_all(
1128
1141
stringify_output = stringify_output ,
1129
1142
sort_by_last_edited = sort_by_last_edited ,
1130
1143
newest_first = newest_first ,
1144
+ query_params = query_params ,
1131
1145
)
1132
1146
1133
1147
# Here we limit the length of the response based on the set_length parameter, see
0 commit comments