Closed simonw closed 2 years ago
Relevant example from https://docs.datasette.io/en/stable/metadata.html#per-database-and-per-table-metadata
{
"databases": {
"database1": {
"tables": {
"example_table": {
"sortable_columns": [
"height",
"weight"
]
}
}
}
}
}
I think this becomes "facet_size": "..."
at the table level, to match the name of the ?_facet_size=100
querystring parameter.
I'm going to do this just at the table level - if you want it at the database level I would imagine usually you would be OK running --setting default_facet_size 10
instead, since most Datasette instances only expose a single database.
I may reconsider this in the future.
In that code self.table
is the name of the current table, but can also be None
if the faceting is being run against a custom SQL query instead (a future feature). self.database
is the name of the current database.
So reading metadata via self.ds
should work fine.
Still needs documentation.
facet_size
is now documented here: https://docs.datasette.io/en/latest/facets.html#facets-in-metadata-json
Suggestion from Discord: https://discord.com/channels/823971286308356157/823971286941302908/1016725586351247430
This is a really good idea, it could be done in
metadata.yml
.