idField
idField<
Brand>(codec):IdTransform<Brand>
Defined in: src/adapters/prisma.ts:170
Creates a read/write transform pair for use with Prisma’s $extends extension model.
Requires a codec variant that exposes a synchronous generate() in addition to safeParse — see IdGeneratingCodec. Only the Timestamp codec and Reverse Timestamp codec qualify; Opaque, Signed, Wrapped, and Digest codecs cannot be passed to idField().
Use computeField(fieldName) to produce a typed $extends result-component
field definition — the brand is carried through Prisma’s type machinery
automatically and no per-call-site cast is required.
For codecs that do not expose a synchronous generate() (Opaque Timestamp,
Signed Timestamp, Wrapped key, Digest), use idFieldNonGenerating instead —
it accepts any IdColumnCodec and omits defaultQuery.
Type Parameters
Section titled “Type Parameters”Brand extends string
Parameters
Section titled “Parameters”IdGeneratingCodec<Brand>
Returns
Section titled “Returns”IdTransform<Brand>
Example
Section titled “Example”import { idField } from "@smonn/ids/prisma";import { createTimestampId } from "@smonn/ids";
const usr = createTimestampId("usr");const userIdField = idField(usr);
const xprisma = prisma.$extends({ result: { user: { id: userIdField.computeField("id") }, },});// xprisma.user.findUnique(…).id is typed as Id<"usr"> — no cast required