nullableIdTransformer
nullableIdTransformer<
Brand>(codec):ValueTransformer
Defined in: src/adapters/typeorm.ts:141
TypeORM column transformer for a nullable Id<Brand> column.
Behaves like idTransformer but from returns null for null /
undefined database values and to passes null / undefined through
unchanged. Use for optional foreign keys.
Type Parameters
Section titled “Type Parameters”Brand extends string
Parameters
Section titled “Parameters”IdColumnCodec<Brand>
Returns
Section titled “Returns”ValueTransformer
Example
Section titled “Example”import { nullableIdTransformer } from "@smonn/ids/typeorm";import { createTimestampId } from "@smonn/ids";import type { Id } from "@smonn/ids";import { Column, Entity } from "typeorm";
const usr = createTimestampId("usr");
@Entity()class Post { @Column({ type: "text", nullable: true, transformer: nullableIdTransformer(usr) }) authorId!: Id<"usr"> | null;}