From 51db5ce26fe244c7bde5ad8fe1b4bdf2374e7f9f Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 18 Feb 2024 18:16:37 +0100 Subject: [PATCH] docs: Add example for ordering by json field Resolves https://github.com/PostgREST/postgrest-docs/issues/364 --- docs/references/api/tables_views.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/references/api/tables_views.rst b/docs/references/api/tables_views.rst index 5f7371cc7..8d5a74d14 100644 --- a/docs/references/api/tables_views.rst +++ b/docs/references/api/tables_views.rst @@ -294,6 +294,21 @@ Note that ``->>`` is used to compare ``blood_type`` as ``text``. To compare with { "id": 12, "age": 30 }, { "id": 15, "age": 35 } ] + +Ordering is also supported: + +.. code-block:: bash + + curl "http://localhost:3000/people?select=id,json_data->age&order=json_data->>age.desc" + +.. code-block:: json + + [ + { "id": 15, "age": 35 }, + { "id": 12, "age": 30 }, + { "id": 11, "age": 25 } + ] + .. _composite_array_columns: Composite / Array Columns