From c0f8e64bbb404886221385bc63482701ccd2fa28 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Thu, 24 May 2018 12:47:52 -0500 Subject: [PATCH] Add limit/offset and and/or to embedded resources --- api.rst | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api.rst b/api.rst index 952f87340..c42d7a7ef 100644 --- a/api.rst +++ b/api.rst @@ -458,10 +458,10 @@ PostgREST can also detect relations going through join tables. Thus you can requ Whenever foreign key relations change in the database schema you must refresh PostgREST's schema cache to allow resource embedding to work properly. See the section :ref:`schema_reloading`. -Embedded Filters and Order --------------------------- +Operations on Embedded Resources +-------------------------------- -Embedded tables can be filtered and ordered similarly to their top-level counterparts. To do so, prefix the query parameters with the name of the embedded table. For instance, to order the actors in each film: +Embedded resources rows can be shaped similarly to their top-level counterparts. To do so, prefix the query parameters with the name of the embedded resource. For instance, to order the actors in each film: .. code-block:: http @@ -475,6 +475,17 @@ This sorts the list of actors in each film but does *not* change the order of th Once again, this restricts the roles included to certain characters but does not filter the films in any way. Films without any of those characters would be included along with empty character lists. +An ``or`` filter can also be used for a similar operation: + +.. code-block:: http + + GET /films?select=*,roles(*)&roles.or=(character.eq.Gummo,character.eq.Zeppo) HTTP/1.1 + +Limit and offset operations are also possible: + +.. code-block:: http + + GET /films?select=*,actors(*)&actors.limit=10&actors.offset=2 HTTP/1.1 Custom Queries ==============