idColumnMysql
idColumnMysql<
Brand>(codec):MySqlCustomColumnBuilder<{columnType:"MySqlCustomColumn";data:Id<Brand>;dataType:"custom";driverParam:string;enumValues:undefined;name:""; }>
Defined in: src/adapters/drizzle.ts:136
Drizzle custom column type that stores an Id<Brand> as a canonical text value in MySQL.
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(), not strict
is(). Throws IdsError("invalid_id") if the value from the database does not
parse as a valid Id<Brand>.
Type Parameters
Section titled “Type Parameters”Brand extends string
Parameters
Section titled “Parameters”IdColumnCodec<Brand>
Returns
Section titled “Returns”MySqlCustomColumnBuilder<{ columnType: "MySqlCustomColumn"; data: Id<Brand>; dataType: "custom"; driverParam: string; enumValues: undefined; name: ""; }>
Example
Section titled “Example”import { idColumnMysql } from "@smonn/ids/drizzle";import { createTimestampId } from "@smonn/ids";
const usr = createTimestampId("usr");export const users = mysqlTable("users", { id: idColumnMysql(usr).primaryKey() });// users.id is Id<"usr"> end-to-end