Skip to content

Commit

Permalink
Some corrections and better wording
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed May 28, 2018
1 parent b11f9ef commit c71bbba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ Casting the columns is possible by suffixing them with the double colon ``::`` p
GET /people?select=full_name,salary::text HTTP/1.1
[
{"fullName": "John Doe", "salary": "90000.00"},
{"fullName": "Jane Doe", "salary": "120000.00"}
{"full_name": "John Doe", "salary": "90000.00"},
{"full_name": "Jane Doe", "salary": "120000.00"}
]
.. _computed_cols:
Expand Down Expand Up @@ -475,10 +475,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`.

Operations on Embedded Resources
--------------------------------
Embedded Operations
-------------------

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:
Embedded resources 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
Expand All @@ -492,19 +492,19 @@ 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:
An ``or`` filter can 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:
Limit and offset operations are possible:

.. code-block:: http
GET /films?select=*,actors(*)&actors.limit=10&actors.offset=2 HTTP/1.1
You can also alias the embedded resources and apply filters on the aliases:
Embedded resources can be aliased and filters can be applied on these aliases:

.. code-block:: http
Expand Down Expand Up @@ -560,7 +560,7 @@ The function parameter names match the JSON object keys in the POST case, for th

.. note::

For versions prior to PostgreSQL 10, to pass a PostgreSQL native array you'll need to quote it as a string:
For versions prior to PostgreSQL 10, to pass a PostgreSQL native array you need to quote it as a string:

.. code:: http
Expand Down Expand Up @@ -772,11 +772,11 @@ You can make an UPSERT with :code:`POST` and the :code:`Prefer: resolution=merge
[
{ "id": 1, "name": "Old employee 1", "salary": 30000 },
{ "id": 2, "name": "Old employee 2" , "salary": 42000 },
{ "id": 3, "name": "New employee 3" , "salary": 50000 }
{ "id": 2, "name": "Old employee 2", "salary": 42000 },
{ "id": 3, "name": "New employee 3", "salary": 50000 }
]
UPSERT merging operates based on the primary key columns, you must specify all of them. You can also choose to ignore the duplicates with :code:`Prefer: resolution=ignore-duplicates`.
UPSERT operates based on the primary key columns, you must specify all of them. You can also choose to ignore the duplicates with :code:`Prefer: resolution=ignore-duplicates`.

A single row UPSERT can be done by using :code:`PUT` and filtering the primary key columns with :code:`eq`:

Expand Down
6 changes: 3 additions & 3 deletions install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ role-claim-key String .role
db-uri
The standard connection PostgreSQL `URI format <https://www.postgresql.org/docs/current/static/libpq-connect.html#AEN45347>`_. Symbols and unusual characters in the password or other fields should be percent encoded to avoid a parse error. If enforcing an SSL connection to the database is required you can use `sslmode <https://www.postgresql.org/docs/9.1/static/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS>`_ in the URI, for example ``postgres://user:pass@host:5432/dbname?sslmode=require``.

When running PostgREST on the same machine as PostgreSQL, it is also possible to connect to the database using a `Unix socket <https://en.wikipedia.org/wiki/Unix_domain_socket>`_ and the `Peer Authentication method <http://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-PEER>`_ as an alternative to TCP/IP communication and authentication with a password, this also grants higher performance. According to the documentation on the `libpq connection string <https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNSTRING>`_ the empty host resolves to the Unix socket and the password can be omitted in this case, so the ``db-uri`` would be reduced to ``postgres://user@/dbname``.
When running PostgREST on the same machine as PostgreSQL, it is also possible to connect to the database using a `Unix socket <https://en.wikipedia.org/wiki/Unix_domain_socket>`_ and the `Peer Authentication method <http://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-PEER>`_ as an alternative to TCP/IP communication and authentication with a password, this also grants higher performance. To do this you can omit the host and the password, e.g. ``postgres://user@/dbname``, see the `libpq connection string <https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNSTRING>`_ documentation for more details.

On older systems like Centos 6, with older versions of libpq, a different db-uri syntax has to be used. In this case the URI is a string of space separated key-value pairs (key=value), so the example above would be :code:`"host=host user=user port=5432 dbname=dbname password=pass"`.
db-schema
Expand Down Expand Up @@ -142,7 +142,7 @@ pre-request
app.settings.*
Arbitrary settings that will become database session settings. This can be used to pass in secret keys directly as strings, or via OS environment variables. For instance: :code:`app.settings.jwt_secret = "$(MYAPP_JWT_SECRET)"` will take :code:`MYAPP_JWT_SECRET` from the environment and make it available to postgresql functions as :code:`current_setting('app.settings.jwt_secret')`.
role-claim-key
A JSPath DSL that specifies the location of the :code:`role` key in the JWT claims. This can be used to consume a JWT provided by a third party service like Auth0, Okta or Keycloak. Some examples:
A JSPath DSL that specifies the location of the :code:`role` key in the JWT claims. This can be used to consume a JWT provided by a third party service like Auth0, Okta or Keycloak. Usage examples:

.. code:: bash
Expand All @@ -151,7 +151,7 @@ role-claim-key
role-claim-key = ".postgrest.roles[1]"
# {"https://www.example.com/role": { "key": "author }}
# non-alphanumerical characters can go inside quotes(escaped in config value)
# non-alphanumerical characters can go inside quotes(escaped in the config value)
role-claim-key = ".\"https://www.example.com/role\".key"
Running the Server
Expand Down

0 comments on commit c71bbba

Please sign in to comment.