Skip to main content

mr query create

Create a new saved query. Requires --name (unique label) and --text (the SQL body). --template is optional and stores raw HTML that the query's page renders under the results table once the query has run. Result rows reach it in the browser as the Alpine variable results and as window.results, not as template variables. Query Text runs on the connection -db-readonly-dsn names; writes are rejected only when that DSN is itself read-only (see query run).

Usage

mr query create

Examples

Create a minimal query

mr query create --name "count-resources" --text "select count(*) as n from resources"

Create with a template for custom display

mr query create --name "recent-notes" --text "select id, name from notes order by created_at desc limit 10" --template '<p>Total results: <span x-text="results.length"></span></p>'

Flags

FlagTypeDefaultDescription
--namestring``Query name (required) (required)
--textstring``Query text/SQL (required) (required)
--templatestring``Query template

Inherited global flags

FlagTypeDefaultDescription
--jsonboolfalseOutput raw JSON
--no-headerboolfalseOmit table headers
--pageint1Page number for list commands (default page size: 50)
--quietboolfalseOnly output IDs
--serverstringhttp://localhost:8181mahresources server URL (env: MAHRESOURCES_URL)

Output

Created query object with ID, Name, Text, Template, Description, CreatedAt, UpdatedAt

Exit Codes

0 on success; 1 on any error

See Also