Skip to content

idColumn

idColumn<Brand>(codec): object

Defined in: src/adapters/kysely.ts:90

Kysely column adapter bound to a codec.

Returns an object with fromDriver / toDriver helpers that mirror the read/write contract of the Drizzle adapter — same error message, same strictness (safeParse on read and write).

Write path: validates the value via codec.safeParse and throws IdsError("invalid_id") if validation fails.

Read path: normalises the raw DB string via codec.safeParse(). Throws if the value does not parse as a valid Id<Brand>.

Brand extends string

IdColumnCodec<Brand>

object

fromDriver(value): Id<Brand>

string

Id<Brand>

toDriver(value): string

Id<Brand>

string

import { idColumn } from "@smonn/ids/kysely";
import { createTimestampId } from "@smonn/ids";
const usr = createTimestampId("usr");
const usrCol = idColumn(usr);
// In a query result handler:
const id = usrCol.fromDriver(row.id);