Conditional writes
A create or update input has an optional property that should be excluded when absent.
Prisma · Pipe
Prisma.skip is a Prisma-provided symbol that explicitly omits a field from a Prisma Client query. Use it instead of undefined when an optional input should not be included.
Prisma.skip is a Prisma-provided symbol for omitting a field from a Prisma Client query. Use it instead of undefined when an optional value should leave that field out of the generated query.
Prisma.skipimport { PrismaClient, Prisma } from "@prisma/client";
const prisma = new PrismaClient();
const optionalEmail: string | undefined = undefined;
await prisma.user.create({
data: {
name: "Alice",
email: optionalEmail ?? Prisma.skip,
},
});Uses Prisma.skip to omit email when the optional value is undefined.
A create or update input has an optional property that should be excluded when absent.
A query builder assembles fields from optional application inputs.
Optional filters must be included only when callers provide values.
Prisma.skip is a symbol supplied by Prisma for omitting a field from a Prisma Client query. It is the explicit replacement for using undefined when an optional value should not be sent.
Follow-up: What expression is useful when a value may be undefined? Use optionalValue ?? Prisma.skip so defined values are retained and undefined values omit the field.
With Prisma.skip, the field is omitted from the query rather than being sent with an undefined value. This makes the omission intentional and explicit.
Follow-up: How does undefined behave in a filter? It effectively means that no filter was defined for that field, so the query does not constrain that column by that key.
A common pattern is to combine a possibly undefined value with the nullish-coalescing operator: optionalValue ?? Prisma.skip. The actual value is used when present; otherwise Prisma.skip omits the field.
Follow-up: Why should this matter for filters? An omitted filter can broaden the query, so optional filtering should be handled deliberately rather than relying on undefined.
undefinednullPrisma Clientnullish coalescing operator