Documentation for filters, plus new documentation unit test

https://simonwillison.net/2018/Jul/28/documentation-unit-tests/
This commit is contained in:
Simon Willison 2019-04-15 15:41:11 -07:00
commit 2c19a27d15
2 changed files with 79 additions and 3 deletions

View file

@ -176,10 +176,68 @@ querystring arguments:
.. _table_arguments:
Special table arguments
-----------------------
Table arguments
---------------
The Datasette table view takes a number of special querystring arguments:
The Datasette table view takes a number of special querystring arguments.
Column filter arguments
~~~~~~~~~~~~~~~~~~~~~~~
You can filter the data returned by the table based on column values using a querystring argument.
``?column__exact=value`` or ``?_column=value``
Returns rows where the specified column exactly matches the value.
``?column__not=value``
Returns rows where the column does not match the value.
``?column__contains=value``
Rows where the string column contains the specified value (``column like "%value%"`` in SQL).
``?column__endswith=value``
Rows where the string column ends with the specified value (``column like "%value"`` in SQL).
``?column__startswith=value``
Rows where the string column starts with the specified value (``column like "value%"`` in SQL).
``?column__gt=value``
Rows which are greater than the specified value.
``?column__gte=value``
Rows which are greater than or equal to the specified value.
``?column__lt=value``
Rows which are less than the specified value.
``?column__lte=value``
Rows which are less than or equal to the specified value.
``?column__like=value``
Match rows with a LIKE clause, case insensitive and with ``%`` as the wildcard character.
``?column__glob=value``
Similar to LIKE but uses Unix wildcard syntax and is case sensitive.
``?column__arraycontains=value``
Works against columns that contain JSON arrays - matches if any of the values in that array match.
This is only available if the ``json1`` SQLite extension is enabled.
``?column__isnull=1``
Matches rows where the column is null.
``?column__notnull=1``
Matches rows where the column is not null.
``?column__isblank=1``
Matches rows where the column is blank, meaning null or the empty string.
``?column__notblank=1``
Matches rows where the column is not blank.
Special table arguments
~~~~~~~~~~~~~~~~~~~~~~~
``?_labels=on/off``
Expand foreign key references for every possible column. See below.