data_grabber
MongoDataGrabber
Source code in api/utils/data_grabber.py
114 115 116 117 118 119 120 121 122 | |
settings
instance-attribute
{ 'where': { 'fields':{ 'secret': 0, 'token': 0, # This will allow search on every field but mentioned ones }, 'operators': { 'in': 1, 'all': 1 # This will allow search using only mentioned operators } }, 'sort': { 'default': [()], 'max_fields': 2, 'fields': { 'name': 1, 'date': 1, # This will allow sort by only mentioned fields } }, 'projection': { 'default': {}, 'policy': 'force' } }
adjust_search_query
adjust_search_query(
initial_query: str,
filtered_query_key: str,
allowed_values: set | None = None,
) -> str
Adjusts the search query by removing the forbidden query keys and then setting it to the required query.
:param initial_query: The initial query in str from which forbidden keys need to be removed. :param filtered_query_key: The forbidden key query need to be removed. :param allowed_values: Optimal structure for filtering by key, jsonable; allowed_values = None allows to drop the key search for user, forcing user to retrieve unfiltered data :return: The adjusted search query in string format.
Source code in api/utils/data_grabber.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | |