Appearance
hailer.insight
Read insights (reports) and their data.
| Method | Host op | Returns |
|---|---|---|
list() | insight.list | Promise<InsightDoc[]> |
data(insightId, options) | insight.data | Promise<InsightData> |
update(insightId, update) | insight.update | Promise<InsightDoc[]> |
query(workspaceId, sources, query) | insight.query | Promise<InsightQueryResult> |
list()
Insights the app can see, projected to { _id, name, publicKey, presets }.
ts
const insights = await hailer.insight.list();- Workspace app — insights in the app's workspace.
- Private app — insights in the user's current workspace.
data(insightId, options)
Run an insight and read its result.
ts
const data = await hailer.insight.data(insightId, {});
const fresh = await hailer.insight.data(insightId, { update: true });The options argument is required. Pass { update: true } to force a recompute. Returns { headers, rows, time } — see InsightData.
update(insightId, update)
ts
const insights = await hailer.insight.update(insightId, { name: 'Renamed' });Takes a partial InsightDoc and returns the updated list.
query(workspaceId, sources, query)
Run an ad-hoc SQL query against Insight sources without saving an insight.
ts
const result = await hailer.insight.query(workspaceId, [
{
name: 'orders',
workflowId,
fields: [{ name: 'status', fieldId }],
},
], 'SELECT status, COUNT(*) AS count FROM orders GROUP BY status');Each source is an InsightSource describing a workflow and the fields to expose as columns of a temporary table named after source.name. The query is a read-only SQLite statement over those tables. Returns InsightQueryResult - { headers, rows, details }, where details maps each table name to its headers and row count. Unlike data(), results are computed on demand, are not cached, and have no row-count cap.
The calling user must be an admin of the workspace.
Related
Insight editor dialogs (create/edit/delete/permission) are opened through hailer.ui.insight. Public (logged-out) insight reads are in hailer.public.insight.