Query — Recipes
Four shapes for four common patterns. Copy the block that matches your app.
The classic dashboard: filter by status, sort by date, paginate.
queryusers
users: {
source: 'main-db',
table: 'public.users',
fields: {
id: { type: 'number', primaryKey: true },
email: { type: 'text' },
role: { type: 'enum', values: ['owner', 'admin', 'member', 'guest'] },
status: { type: 'enum', values: ['active', 'invited', 'suspended'] },
last_seen: { type: 'date' },
},
grants: { query: 'staff' },
}
Full walk over a date range, piped to CSV or an analytics sink.
queryevents
events: {
source: 'analytics',
table: 'public.events',
fields: {
id: { type: 'number', primaryKey: true },
kind: { type: 'enum', values: ['view', 'signup', 'purchase', 'refund'] },
occurred_at: { type: 'date' },
user_id: { type: 'number' },
amount: { type: 'number' },
},
grants: {
query: 'staff',
stream: { query: 'staff' },
},
}
The e-commerce sidebar: multiple filters, operator ranges, price-sort.
queryproducts
products: {
source: 'main-db',
table: 'public.products',
fields: {
id: { type: 'number', primaryKey: true },
name: { type: 'text' },
category: { type: 'enum', values: ['footwear', 'apparel', 'accessories'] },
price: { type: 'number' },
in_stock: { type: 'boolean' },
},
grants: { query: 'public' },
}
"Show me what this customer did in the last hour." Cursor-paginated to stay
live as new rows arrive.
queryevents
events: {
source: 'analytics',
table: 'public.events',
fields: {
id: { type: 'number', primaryKey: true },
kind: { type: 'enum', values: ['view', 'click', 'signup', 'purchase'] },
occurred_at: { type: 'date' },
user_id: { type: 'number' },
metadata: { type: 'json' },
},
grants: { query: 'authenticated' },
}