mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Initial attempt at /db/table/row/-/delete, refs #1864
This commit is contained in:
parent
2865d3956f
commit
00632ded30
6 changed files with 144 additions and 4 deletions
|
|
@ -559,6 +559,18 @@ Actor is allowed to insert rows into a table.
|
|||
|
||||
Default *deny*.
|
||||
|
||||
.. _permissions_delete_row:
|
||||
|
||||
delete-row
|
||||
----------
|
||||
|
||||
Actor is allowed to delete rows from a table.
|
||||
|
||||
``resource`` - tuple: (string, string)
|
||||
The name of the database, then the name of the table
|
||||
|
||||
Default *deny*.
|
||||
|
||||
.. _permissions_drop_table:
|
||||
|
||||
drop-table
|
||||
|
|
|
|||
|
|
@ -540,6 +540,25 @@ To return the newly inserted rows, add the ``"return_rows": true`` key to the re
|
|||
|
||||
This will return the same ``"inserted"`` key as the single row example above. There is a small performance penalty for using this option.
|
||||
|
||||
.. _RowDeleteView:
|
||||
|
||||
Deleting rows
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
To delete a row, make a ``POST`` to ``/<database>/<table>/<row-pks>/-/delete``. This requires the :ref:`permissions_delete_row` permission.
|
||||
|
||||
::
|
||||
|
||||
POST /<database>/<table>/<row-pks>/-/delete
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer dstok_<rest-of-token>
|
||||
|
||||
``<row-pks>`` here is the :ref:`tilde-encoded <internals_tilde_encoding>` primary key value of the row to delete - or a comma-separated list of primary key values if the table has a composite primary key.
|
||||
|
||||
If successful, this will return a ``200`` status code and a ``{"ok": true}`` response body.
|
||||
|
||||
Any errors will return ``{"errors": ["... descriptive message ..."], "ok": false}``, and a ``400`` status code for a bad input or a ``403`` status code for an authentication or permission error.
|
||||
|
||||
.. _TableDropView:
|
||||
|
||||
Dropping tables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue