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();
},
});
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;
myIntegerDateColumn: ZodDate;
myTextDateColumn: ZodAny;
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server