mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Support title/description for canned queries, closes #342
Demo here: https://latest.datasette.io/fixtures/neighborhood_search
This commit is contained in:
parent
58fec99ab0
commit
6e37f091ed
9 changed files with 62 additions and 17 deletions
|
|
@ -73,7 +73,9 @@ queries inside your ``metadata.json`` file. Here's an example::
|
|||
"databases": {
|
||||
"sf-trees": {
|
||||
"queries": {
|
||||
"just_species": "select qSpecies from Street_Tree_List"
|
||||
"just_species": {
|
||||
"sql": select qSpecies from Street_Tree_List"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -92,6 +94,11 @@ For the above example, that URL would be::
|
|||
|
||||
/sf-trees/just_species
|
||||
|
||||
You can optionally include ``"title"`` and ``"description"`` keys to show a
|
||||
title and description on the canned query page. As with regular table metadata
|
||||
you can alternatively specify ``"description_html"`` to have your description
|
||||
rendered as HTML (rather than having HTML special characters escaped).
|
||||
|
||||
Canned queries support named parameters, so if you include those in the SQL you
|
||||
will then be able to enter them using the form fields on the canned query page
|
||||
or by adding them to the URL. This means canned queries can be used to create
|
||||
|
|
@ -111,7 +118,11 @@ In the canned query JSON it looks like this::
|
|||
"databases": {
|
||||
"fixtures": {
|
||||
"queries": {
|
||||
"neighborhood_search": "select neighborhood, facet_cities.name, state\nfrom facetable join facet_cities on facetable.city_id = facet_cities.id\nwhere neighborhood like '%' || :text || '%' order by neighborhood;"
|
||||
"neighborhood_search": {
|
||||
"sql": "select neighborhood, facet_cities.name, state\nfrom facetable join facet_cities on facetable.city_id = facet_cities.id\nwhere neighborhood like '%' || :text || '%' order by neighborhood;",
|
||||
"title": "Search neighborhoods",
|
||||
"description_html": "<b>Demonstrating</b> simple like search"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue