{"id":29099914,"url":"https://github.com/bcc-code/directus-sql-query-panel","last_synced_at":"2025-06-28T17:37:55.211Z","repository":{"id":205981751,"uuid":"715552059","full_name":"bcc-code/directus-sql-query-panel","owner":"bcc-code","description":"Insights Panel for viewing results for dynamic sql queries","archived":false,"fork":false,"pushed_at":"2025-04-14T08:37:19.000Z","size":533,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T09:43:32.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcc-code.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-07T11:24:16.000Z","updated_at":"2025-04-14T08:37:08.000Z","dependencies_parsed_at":"2024-02-09T19:25:50.034Z","dependency_job_id":"1cd306e7-3aed-4a67-9c62-0ae0537438bb","html_url":"https://github.com/bcc-code/directus-sql-query-panel","commit_stats":null,"previous_names":["bcc-code/directus-sql-query-panel"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/bcc-code/directus-sql-query-panel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fdirectus-sql-query-panel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fdirectus-sql-query-panel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fdirectus-sql-query-panel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fdirectus-sql-query-panel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcc-code","download_url":"https://codeload.github.com/bcc-code/directus-sql-query-panel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcc-code%2Fdirectus-sql-query-panel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262471025,"owners_count":23316600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-28T17:37:48.264Z","updated_at":"2025-06-28T17:37:55.204Z","avatar_url":"https://github.com/bcc-code.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL Query Panel\n\nView the result of your SQL query in a tabular panel with Directus Insights.\n\n## Supports\n\n- Global Variables\n- Static Queries\n- `CALL` statements\n- Downloading results as CSV\n- Summary row with count, sum, average, count unique and count groups\n- Columns can be made searchable, sortable and marked as numeric\n- Actions can be added to an entire row or as buttons at the end of each row with support for adding values from result\n- **Security** panel results can only be viewed by users with access to those panels, so you can adjust permissions on a per panel basis via Directus Access\n\n\n## Install\n\n### Via npm\n\n`npm install directus-extension-sql-query-panel`\n\n## Usage\n\nAdd a new panel and select the `SQL Query panel` type.\n\nEnter your SQL query, optionally adding global variables wrapped in `{{ }}` to make your query dynamic.\n\nBy default a table will be generated with the selected columns from your query, however you can manually add columns you want to display and configure them.\n\nIf you do not use variables, you can mark the panel as static.\n\n## Events\n\nThere are two events that are fired when a query is executed:\n\n\t- `sql-query:request` - Fired before variables are replaced in the query (payload: `{ variables: Record\u003cstring, any\u003e, query: string }`, request)\n\t- `sql-query:response` - Fired after the query has been executed (payload: `{items: Record\u003cstring, any\u003e[], headers: string[]}`, request)\n\nUse it to add your own logic to the query, for example:\n\n```js\n// Check or modify the variables and query before it gets executed\nemitter.onFilter('sql-query:request', async ({ variables, query }, req) =\u003e {\n\t// Ensure the current user has access to the tenant\n\tif (query.includes('{{tenant}}') \u0026\u0026 variables.tenant) {\n\t\tconst tenantSrv = new ItemsService('tenants', req);\n\t\ttry {\n\t\t\tawait tenantSrv.readOne(variables.tenant, { fields: ['id'] });\n\t\t} catch (e) { throw new Error('Invalid tenant'); }\n\t}\n\n\t// Add tenant if not already present eg.\n\t// variables.tenant = req.user.tenantId;\n\n\treturn { variables, query };\n})\n```\n\n## Contributing\n\nPRs are welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcc-code%2Fdirectus-sql-query-panel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcc-code%2Fdirectus-sql-query-panel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcc-code%2Fdirectus-sql-query-panel/lists"}