mr mrql run
Execute a saved MRQL query by name or numeric ID. The argument is tried
as an ID first and then as a name, so a name that happens to be numeric
can still be resolved. Returns the same shape as a one-off mrql call:
either a standard result with an entityType plus the matching entity
arrays, or -- for GROUP BY queries -- a grouped result with mode
(aggregated or bucketed) and rows / groups.
An aggregated result also carries columns: the column names in the
order the query wrote them, group-by fields first and then aggregates.
The table output and mrql export --format csv both follow it, so the
two agree. Read columns rather than the key order of a rows entry --
a JSON object carries no order.
A bucketed result carries keyColumns for the same reason: the
group-by key names in the order the query wrote them. The per-bucket
header line and the CSV export's leading columns both follow it. A
bucket's key object may hold entries keyColumns does not name -- a
bucket keyed on a relation field also gets <field>_id so two
same-named groups stay apart -- and those are printed after the named
ones.
Pagination and shaping flags (--limit, --buckets, --offset, plus
the global --page) apply to the stored query exactly as they would to
an inline mrql invocation. Pass --render to request server-side
template rendering via the CustomMRQLResult template. A missing ID or
name returns HTTP 404.
If the saved query contains $name parameter placeholders, bind them
with repeatable --param name=value flags. Every placeholder must be
supplied or the run returns HTTP 400.
This is distinct from query run, which executes SQL-backed Query
records rather than MRQL DSL expressions.
Usage
mr mrql run <name-or-id>
Positional arguments:
<name-or-id>
Examples
Run a saved query by ID
mr mrql run 42
Run by name with bucketed GROUP BY pagination
mr mrql run "resources-by-type" --buckets 5
Run and extract result ids with jq
mr mrql run "recent-photos" --json | jq -r '.resources[].ID'
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--limit | int | 0 | Items per bucket for GROUP BY, or total items for regular queries |
--buckets | int | 0 | Groups per page for bucketed GROUP BY queries |
--offset | int | 0 | Bucket offset for cursor-based GROUP BY pagination |
--render | bool | false | Request server-side template rendering via CustomMRQLResult |
--param | stringArray | [] | Bind a query parameter placeholder, repeatable: --param name=value |
Inherited global flags
| Flag | Type | Default | Description |
|---|---|---|---|
--json | bool | false | Output raw JSON |
--no-header | bool | false | Omit table headers |
--page | int | 1 | Page number for list commands (default page size: 50) |
--quiet | bool | false | Only output IDs |
--server | string | http://localhost:8181 | mahresources server URL (env: MAHRESOURCES_URL) |
Output
MRQL result object with entityType (string) and resources/notes/groups arrays, or a grouped result with mode + rows/groups for GROUP BY queries
Exit Codes
0 on success; 1 on any error