Add specify columns reference

This commit is contained in:
steve-chavez
2019-08-26 10:28:03 -05:00
committed by Steve Chávez
parent 2414c7f7f0
commit 51c0ad3e0c
+30
View File
@@ -832,6 +832,8 @@ Result:
[ 3, 7 ]
It's also possible to :ref:`Specify Columns <specify_columns>` on functions calls.
Function filters
----------------
@@ -1066,6 +1068,34 @@ To bulk insert JSON post an array of objects having all-matching keys
{ "name": "Janus", "age": 10, "height": 55 }
]
.. _specify_columns:
Specifying Columns
------------------
By using the :code:`columns` query parameter it's possible to specify the payload keys that will be inserted/updated
and ignore the rest of the payload.
.. code-block:: http
POST /datasets?columns=source,publication_date,figure HTTP/1.1
Content-Type: application/json
{
"source": "Natural Disaster Prevention and Control",
"publication_date": "2015-09-11",
"figure": 1100,
"location": "...",
"comment": "...",
"extra": "...",
"stuff": "..."
}
In this case, only **source**, **publication_date** and **figure** will be inserted. The rest of the JSON keys will be ignored.
Using this also has the side-effect of being more efficient for :ref:`bulk_insert` since PostgREST will not process the JSON and
it'll send it directly to PostgreSQL.
Upsert
------