Ability to add descending order indexes (#262)

* DescIndex(column) for descending index columns, refs #260
* Ability to add desc indexes using CLI, closes #260
This commit is contained in:
Simon Willison 2021-05-28 22:01:38 -07:00 committed by GitHub
commit 51d01da30d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 4 deletions

View file

@ -1866,6 +1866,17 @@ By default the index will be named ``idx_{table-name}_{columns}`` - if you want
index_name="good_dogs_by_age"
)
To create an index in descending order for a column, wrap the column name in ``db.DescIndex()`` like this:
.. code-block:: python
from sqlite_utils.db import DescIndex
db["dogs"].create_index(
["is_good_dog", DescIndex("age")],
index_name="good_dogs_by_age"
)
You can create a unique index by passing ``unique=True``:
.. code-block:: python