datasette/docs
Simon Willison ed631e690b
?_labels= and ?_label=COL to expand foreign keys in JSON/CSV
These new querystring arguments can be used to request expanded foreign keys
in both JSON and CSV formats.

?_labels=on turns on expansions for ALL foreign key columns

?_label=COLUMN1&_label=COLUMN2 can be used to pick specific columns to expand

e.g. `Street_Tree_List.json?_label=qSpecies&_label=qLegalStatus`

    {
        "rowid": 233,
        "TreeID": 121240,
        "qLegalStatus": {
            "value" 2,
            "label": "Private"
        }
        "qSpecies": {
            "value": 16,
            "label": "Sycamore"
        }
        "qAddress": "91 Commonwealth Ave",
        ...
    }

The labels option also works for the HTML and CSV views.

HTML defaults to `?_labels=on`, so if you pass `?_labels=off` you can disable
foreign key expansion entirely - or you can use `?_label=COLUMN` to request
just specific columns.

If you expand labels on CSV you get additional columns in the output:

`/Street_Tree_List.csv?_label=qLegalStatus`

    rowid,TreeID,qLegalStatus,qLegalStatus_label...
    1,141565,1,Permitted Site...
    2,232565,2,Undocumented...

I also refactored the existing foreign key expansion code.

Closes #233. Refs #266.
2018-06-16 15:18:57 -07:00
..
.gitignore Added initial docs, including a changelog 2017-11-16 07:11:00 -08:00
Makefile Added initial docs, including a changelog 2017-11-16 07:11:00 -08:00
auto-build.sh Added --load-extension argument to datasette serve 2017-11-16 08:48:49 -08:00
changelog.rst 0.22.1 bugfix release 2018-05-23 07:00:01 -07:00
conf.py Update conf.py 2018-05-12 09:08:11 -03:00
config.rst Documented how to set multiple --config at once 2018-06-04 18:45:47 -07:00
custom_templates.rst Hyperlink to www.srihash.org 2018-05-26 12:46:24 -07:00
facets.png Added screenshots to facets and full_text_search docs, refs #255 2018-05-16 08:27:24 -07:00
facets.rst Updated default facet limits in docs 2018-05-18 08:50:37 -07:00
full_text_search.png Added screenshots to facets and full_text_search docs, refs #255 2018-05-16 08:27:24 -07:00
full_text_search.rst SQL syntax highlighting in docs 2018-05-31 06:17:53 -07:00
getting_started.rst Renamed --limit to --config, added --help-config, closes #274 2018-05-20 10:01:49 -07:00
index.rst Initial documentation on using SpatiaLite 2018-05-26 11:04:09 -07:00
introspection.rst Link to /-/plugins example 2018-05-20 21:07:26 -07:00
json_api.rst ?_labels= and ?_label=COL to expand foreign keys in JSON/CSV 2018-06-16 15:18:57 -07:00
metadata.rst ?_labels= and ?_label=COL to expand foreign keys in JSON/CSV 2018-06-16 15:18:57 -07:00
plugins.rst Datasette 0.20: static assets and templates for plugins 2018-04-20 07:32:02 -07:00
spatialite.rst SQL syntax highlighting in docs 2018-05-31 06:17:53 -07:00
sql_queries.rst --limit= mechanism plus new limits for facets 2018-05-17 22:08:26 -07:00