toPrismaWhere
function toPrismaWhere(input): | PrismaWhere | undefined;Defined in: filters/prisma.ts:244
Render an already-compiled CompiledWhere AST (from compileFilters /
compileFilterNode in @xtandard/lib/filters) to a Prisma where object, looking each field
up in fields. Conditions on fields missing from fields are dropped; null (or an AST
that drops to nothing) gives undefined. and/or/not become AND/OR/NOT. Throws
for arrayContained and for like/ilike patterns with an inner % or any _. Most code
calls buildWhere, which compiles and renders in one step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ fields: Record<string, string>; where: | CompiledWhere | null; } |
input.fields |
Record<string, string> |
input.where |
| CompiledWhere | null |
Returns
Section titled “Returns”| PrismaWhere
| undefined
Example
Section titled “Example”import { toPrismaWhere } from "@xtandard/lib/filters/prisma";
toPrismaWhere({ where: { type: "and", nodes: [ { type: "cond", cond: { field: "amount", op: "gt", value: 5 } }, { type: "cond", cond: { field: "name", op: "isNotNull" } }, ] }, fields: { amount: "amount", name: "name" },});// → { AND: [{ amount: { gt: 5 } }, { name: { not: null } }] }