/db/table/-/drop API, closes #1874

This commit is contained in:
Simon Willison 2022-10-30 15:17:21 -07:00
commit 2865d3956f
6 changed files with 114 additions and 11 deletions

View file

@ -559,6 +559,18 @@ Actor is allowed to insert rows into a table.
Default *deny*.
.. _permissions_drop_table:
drop-table
----------
Actor is allowed to drop a database table.
``resource`` - tuple: (string, string)
The name of the database, then the name of the table
Default *deny*.
.. _permissions_execute_sql:
execute-sql

View file

@ -539,3 +539,20 @@ 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.
.. _TableDropView:
Dropping tables
~~~~~~~~~~~~~~~
To drop a table, make a ``POST`` to ``/<database>/<table>/-/drop``. This requires the :ref:`permissions_drop_table` permission.
::
POST /<database>/<table>/-/drop
Content-Type: application/json
Authorization: Bearer dstok_<rest-of-token>
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.