Skip to content

Latest commit

 

History

History
87 lines (56 loc) · 1.48 KB

api_filtering_example.rst

File metadata and controls

87 lines (56 loc) · 1.48 KB

Filtering API example

.. literalinclude:: ../examples/custom_filter_example.py
    :language: python



Filter by jsonb contains

[
  {
    "name": "words",
    "op": "jsonb_contains",
    "val": {"location": "Moscow", "spam": "eggs"}
  }
]

Request:

.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array
  :language: HTTP

Response:

.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array_result
  :language: HTTP


Other examples

# pseudo-code

class User:
    name: str = ...
    words: list[str] = ...

Filter by word

[
  {
    "name": "words",
    "op": "in",
    "val": "spam"
  }
]

Request:

.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_in_array
  :language: HTTP

Response:

.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_word_in_array_result
  :language: HTTP


Filter by words

[
  {
    "name": "words",
    "op": "in",
    "val": ["bar", "eggs"]
  }
]

Request:

.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_words_in_array
  :language: HTTP

Response:

.. literalinclude:: ./http_snippets/snippets/api_filtering__get_users__filter_words_in_array_result
  :language: HTTP