Suggestion: Hiding columns
As there's the possibility of hiding tables - I've run into the need of hiding specific columns - data that's either not relevant for public or can't be shown due to privacy reasons.
There's a ?_nocol=x argument you can use to hide a column when you link to a table, but that won't help you if you need to hide the column for privacy reasons: https://docs.datasette.io/en/latest/json_api.html#special-table-arguments
One solution right now is to define a SQL view for the things that you DO want people to be able to see, and then use Datasette's permission system to hide the tables ('"allow": false in metadata for each table) but show the views.
If you want to redact specific columns there's a plugin for doing that: https://datasette.io/plugins/datasette-mask-columns
This does make sense as more of a core Datasette feature though - tagging it as a feature suggestion.
The problem (in my particular use case) with using a VIEW is that I'd need one of the columns to be searchable – but that (enable-fts) doesn't work with views :/
__ side-suggestion: I don't know how feasible this might be, but when one column (or table) would be marked as hidden, could the Download SQLite DB link take that into account? 🧐
I'm running into a similar use case as pax above- I made a nice view that just has the data I'm interested in (which doesn't include the id, since it's not important in this case). But, by excluding id from the view, I can't do fts queries against it because the view has no id field to tie to rowid:
ERROR: conn=<sqlite3.Connection object at 0x106521210>,
sql = 'select time, text, permalink, num_children from nice where id in
(select rowid from items_fts where items_fts match :search) limit 101',
params = {'search': 'whatever'}: no such column: id
It works fine when I include id in my view, but now my nice view is cluttered up. Would be great to hide it permanently in the config.json.
Bumping this as I'm not exactly sure where my use case falls with the suggestions provided. I'd like to exclude some columns from view for compactness and clarity.
One solution right now is to define a SQL view for the things that you DO want people to be able to see, and then use Datasette's permission system to hide the tables ('"allow": false in metadata for each table) but show the views.
Do you have an example of this?
Configuring it in the metadata I think would be ideal.
Creating a view is a pretty good workaround but a little limited. FTS at least doesn't work on views.
To @miklb's question, making a view is as simple as
create view SimplerTable as
select foo, bar from OriginalTable;
I found another hack to hide columns that works pretty well for me. Add custom CSS, like this
td.col-popup, th.col-popup { display: none; }
td.col-lat, th.col-lat { display: none; }
td.col-lon, th.col-lon { display: none; }
td.col-rowid, th.col-rowid { display: none; }
That's a set I'm using along with cluster-map so the map metadata isn't visible in the table.
Not as good as actually filtering out columns: they're still present in the web page. But at least they don't take up space on the screen.