toPostgrestParams
function toPostgrestParams(input): PostgrestParams;Defined in: filters/postgrest.ts:396
Render an already-compiled CompiledWhere AST (from compileFilters /
compileFilterNode in @xtandard/lib/filters) to PostgREST query parameters, looking each
field up in columns. Conditions on fields missing from columns are dropped; null (or an
AST that drops to nothing) gives []. A top-level and becomes one param per condition
(PostgREST ANDs them); or → or=(…), a negated group → not.or=(…)/not.and=(…), a
negated condition → the not. operator prefix. Most code calls buildParams, which compiles
and renders in one step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ columns: Record<string, string>; where: | CompiledWhere | null; } |
input.columns |
Record<string, string> |
input.where |
| CompiledWhere | null |
Returns
Section titled “Returns”Example
Section titled “Example”import { toPostgrestParams } from "@xtandard/lib/filters/postgrest";
toPostgrestParams({ where: { type: "or", nodes: [ { type: "cond", cond: { field: "amount", op: "gt", value: 5 } }, { type: "not", node: { type: "cond", cond: { field: "name", op: "isNull" } } }, ] }, columns: { amount: "amount", name: "name" },});// → [["or", "(amount.gt.5,name.not.is.null)"]]