Bier.Mutation (bier v0.1.0)

Copy Markdown View Source

Write pipeline for POST / PATCH / PUT / DELETE on a relation.

Mirrors PostgREST's mutation semantics:

  • POSTINSERT ... RETURNING, optionally ON CONFLICT for upsert (Prefer: resolution=merge-duplicates|ignore-duplicates, ?on_conflict=).
  • PATCHUPDATE ... WHERE <filters> RETURNING, honoring the request's column filters.
  • DELETEDELETE ... WHERE <filters> RETURNING.
  • PUT — single-row upsert keyed by the request's PK filter (INSERT ... ON CONFLICT (<pk>) DO UPDATE).

Row values arrive as a JSON payload and are expanded into typed columns through Postgres' jsonb_array_elements (one bound jsonb parameter), so a string like "{1,2,3}" coerces to integer[] exactly as PostgREST does; user data is never interpolated. The ?columns= param selects which payload keys become target columns (others are ignored); Prefer: missing=default fills the column DEFAULT for keys a row omits.

The Prefer: return= token selects the response shape; Preference-Applied echoes the honored tokens in PostgREST's canonical order.

Summary

Functions

Handle a mutation request after media negotiation.

Functions

handle(conn, config, relation, media)

Handle a mutation request after media negotiation.