-
-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
canned_queries() plugin hook #852
Comments
Question about this on Twitter: https://twitter.com/amjithr/status/1273440766862352384 |
The easiest way to do this would be with a new plugin hook:
Another approach would be to make the whole of I think I like the dedicated |
It would be neat if the queries returned by this hook could be restricted to specific users. I think I can do that by returning an "allow" block as part of the query. But... what if we allow users to save private queries and we might have thousands of users each with hundreds of saved queries? For that case it would be good if the plugin hook could take an optional This would also allow us to dynamically generate a canned query for "return the bookmarks belonging to this actor" or similar! |
@hookspec
def canned_queries(datasette, database, actor):
"Return a dictionary of canned query definitions or an awaitable function that returns them" |
Released an alpha preview in https://github.com/simonw/datasette/releases/tag/0.45a1 Wrote about this here: https://simonwillison.net/2020/Jun/19/datasette-alphas/ |
I'll close this once I've built a plugin against it. |
Plugin idea: Then it returns any queries from that table as additional canned queries. Bonus idea: it could write the user's actor_id to a column if they are signed in, and provide a link to see "just my saved queries" in that case. |
New repo: https://github.com/simonw/datasette-saved-queries - which I created using the new cookiecutter template at https://github.com/simonw/datasette-plugin |
Canned queries are currently baked into
metadata.json
which is read once on startup.Allowing users to interactively create new canned queries - even if just through a plugin - would make a lot of sense.
Is this a new plugin hook or some other mechanism? Lots to think about here.
The text was updated successfully, but these errors were encountered: