The SQL expression of a response body column, by media type: PostgREST's asJsonF,
asJsonSingleF, addNullsToSnip and asCsvF.
The expression aggregates the _postgrest_t rows of the statement's final select, and
shape says how:
:rows- a JSON array of the rows:single_composite- the first row as one object, ornull(the object media type, or a function returning one row):scalar_set- a JSON array of thepgrst_scalarcolumn:scalar- the firstpgrst_scalarvalue, ornull
With nulls_stripped? the JSON aggregate is wrapped in json_strip_nulls(...). CSV is the
same for every shape: a header, a newline, then each row's text form without its enclosing
parentheses, one per line. The rows' text is Postgres' record output (its own quoting), which
is what PostgREST sends. The header is unquoted column names, from header:
:first_row(default) - the keys of the first row ofpgrst_source, as PostgREST'sasCsvF: empty when there is no row{:expr, sql}- a SQL text expression for the names, whatever the rows (a call's or a write's body columns). The caller binds the names; they are request text (aliases) and never spliced
Differences from PostgREST
A call's or write's CSV header lists exactly the columns the body carries, empty results
included. PostgREST v14.18 also adds unselected filter and key columns to the header:
GET /rpc/getallprojects?select=name&id=eq.1 answers header id,name over a one-column body.
It also sorts the names and names the column behind an alias. We treat that as a bug and do
not copy it.
Summary
Functions
The body expression (text) for media and shape.
Types
Functions
@spec body(PgRest.MediaType.t(), shape(), :first_row | {:expr, iodata()}) :: iodata()
The body expression (text) for media and shape.