How to make a text based timestamp type for sqlite with zod schema inference

When I use the built in integer with mode timestamp, the generated zod schemas correctly declare that inserts take a Date and selects produce a Date.

When I try and write a custom type like this:
const timestamp = customType<
  { data: Date; driverData: string; }
>({
  dataType() {
    return 'text';
  },
  fromDriver(value: string): Date {
    return new Date(value);
  },
  toDriver(value: Date): string {
    return value.toISOString();
  },
});


The zod schema looks like this:
myIntegerDateColumn: ZodDate;
myTextDateColumn: ZodAny;
Was this page helpful?