{"ok": true, "database": "docs", "table": "sections", "rows": [{"id": "plugin_hooks:plugin-hook-jump-items-sql", "page": "plugin_hooks", "ref": "plugin-hook-jump-items-sql", "title": "jump_items_sql(datasette, actor, request)", "content": "datasette  -  Datasette class \n                     \n                         You can use this to access plugin configuration options via  datasette.plugin_config(your_plugin_name) , or to execute SQL queries. \n                     \n                 \n                 \n                     actor  - dictionary or None \n                     \n                         The currently authenticated  actor . \n                     \n                 \n                 \n                     request  -  Request object \n                     \n                         The current HTTP request. \n                     \n                 \n             \n             This hook allows plugins to add extra results to Datasette's  /  jump menu, which is powered by the  /-/jump  JSON endpoint. \n             Return a  datasette.jump.JumpSQL  object, or a list of  JumpSQL  objects. Each  JumpSQL  object wraps a SQL query to be searched alongside Datasette's own databases, tables, views and stored query results. The hook can also be an  async def  function, or return an awaitable that resolves to one of these values. \n             JumpSQL  queries run against Datasette's internal database by default. To run a query against another database, pass its name as the optional  database=  argument. For example,  JumpSQL(database=\"content\", sql=\"...\")  runs against the  content  database. \n             Datasette groups  JumpSQL  queries by database and executes one  UNION ALL  query for each database. \n             The SQL query must return these columns: \n             \n                 \n                     type \n                     \n                         A short type string for the result, for example  \"app\"  or  \"dashboard\" . The jump menu displays this above the item as a category label. \n                     \n                 \n                 \n                     label \n                     \n                         The stable name for the result. This is returned as  name  in the JSON API and is used for sorting. \n                     \n                 \n                 \n                     description \n                     \n                         Optional longer text describing this individual item, or  NULL . The jump menu displays this below the item's URL when it is present. \n                     \n                 \n                 \n                     url \n                     \n                         The URL to navigate to when the item is selected. This can be either a string starting with  /  or a JSON object describing a call to one of the  datasette.urls  methods. For example,  json_object('method', 'table', 'database', 'fixtures', 'table', 'facetable')  calls  datasette.urls.table(database='fixtures', table='facetable') . Unknown methods or invalid named arguments will result in an error. \n                     \n                 \n                 \n                     search_text \n                     \n                         Text that should be searched by the  ?q=  parameter. \n                     \n                 \n                 \n                     display_name \n                     \n                         A human-readable label for the result, or  NULL . Datasette returns this as  display_name  in the JSON API, and the jump menu shows it as the primary readable label with  name  shown underneath. \n                     \n                 \n             \n             Use  params=  to pass SQL parameters. Datasette will automatically namespace those parameters before adding the SQL fragment to the per-database  UNION ALL  query. \n             This example returns a SQL fragment that searches rows from a  dashboards  table in the  content  database. The  url  column uses  json_object()  to describe a call to  datasette.urls.row(database='content', table='dashboards', row_path=slug) : \n             from datasette import hookimpl\nfrom datasette.jump import JumpSQL\n\n\n@hookimpl\ndef jump_items_sql(datasette, actor, request):\n    if not actor:\n        return None\n    return JumpSQL(\n        sql=\"\"\"\n        SELECT\n            'dashboard' AS type,\n            slug AS label,\n            description,\n            json_object(\n                'method', 'row',\n                'database', 'content',\n                'table', 'dashboards',\n                'row_path', slug\n            ) AS url,\n            slug || ' ' || COALESCE(title, '') || ' ' || COALESCE(description, '') AS search_text,\n            title AS display_name\n        FROM dashboards\n        WHERE owner_id = :actor_id\n        \"\"\",\n        params={\"actor_id\": actor[\"id\"]},\n        database=\"content\",\n    ) \n             This example uses the  JumpSQL.menu_item()  shortcut to add a single \"Plugin dashboard\" result for signed-in users: \n             from datasette import hookimpl\nfrom datasette.jump import JumpSQL\n\n\n@hookimpl\ndef jump_items_sql(datasette, actor, request):\n    if not actor:\n        return None\n    return JumpSQL.menu_item(\n        item_type=\"dashboard\",\n        label=\"plugin-dashboard\",\n        description=\"Review plugin status and configuration.\",\n        url=\"/-/plugin-dashboard\",\n        search_text=\"plugin dashboard\",\n        display_name=\"Plugin dashboard\",\n    ) \n             JumpSQL.menu_item(...)  is a shortcut for adding a single jump menu item from Python code. It accepts the keyword arguments shown above.", "breadcrumbs": "[\"Plugin hooks\"]", "references": "[]"}], "primary_keys": ["id"], "primary_key_values": ["plugin_hooks:plugin-hook-jump-items-sql"], "query_ms": 2.5598180072847754, "truncated": false}