diff --git a/docs/api.rst b/docs/api.rst index 54426024e..5d34ecf77 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1720,6 +1720,39 @@ Doing a full table update without filters is not allowed and will result in 0 up Updates also support :code:`Prefer: return=representation` plus :ref:`v_filter`. +.. _bulk_update: + +Bulk Update +----------- + +You can update rows with different data by providing a JSON array of objects having uniform keys, the rows will be chosen based on the primary key column(s) values. + +.. tabs:: + + .. code-tab:: http + + PATCH /employees HTTP/1.1 + + [ + { "id": 1, "name": "Renamed employee 1", "salary": 40000 }, + { "id": 2, "name": "Renamed employee 2", "salary": 52000 }, + { "id": 3, "name": "Renamed employee 3", "salary": 60000 } + ] + + .. code-tab:: bash Curl + + curl "http://localhost:3000/employees" \ + -X PATCH -H "Content-Type: application/json" \ + -d @- << EOF + [ + { "id": 1, "name": "Renamed employee 1", "salary": 40000 }, + { "id": 2, "name": "Renamed employee 2", "salary": 52000 }, + { "id": 3, "name": "Renamed employee 3", "salary": 60000 } + ] + EOF + +You must not include any filters for this to work. If you provide filters, only the values of the first object in the array will be used for the update. + .. _upsert: Upsert diff --git a/docs/releases/latest.rst b/docs/releases/latest.rst index e09ccb247..3b7eaaf97 100644 --- a/docs/releases/latest.rst +++ b/docs/releases/latest.rst @@ -10,6 +10,11 @@ Features API ~~~ +Bulk Update +^^^^^^^^^^^ + +See :ref:`bulk_update`. + Access Composite Type fields and Array elements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/postgrest.dict b/postgrest.dict index 2262fe9bc..d1430e1f6 100644 --- a/postgrest.dict +++ b/postgrest.dict @@ -182,6 +182,8 @@ unicode unix updatable UPSERT +Upsert +upsert uri url urls