johtso
johtso
Explore posts from servers
DTDrizzle Team
Created by johtso on 6/28/2024 in #help
Monorepo and schemas, how to structure
I was wondering if anyone had any advice/thoughts on how best to structure a monorepo project when it comes to schemas. I currently have a single "database" package that has all my schemas and migrations. Is there a "better" way to do it? It seems wrong to have the schemas separate form the package that it relates to, but at the same time it seems simpler than trying to figure out a way to manage schemas and migrations across multiple packages..
1 replies
DTDrizzle Team
Created by johtso on 3/31/2024 in #help
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;
1 replies
DTDrizzle Team
Created by johtso on 3/31/2024 in #help
How do I access config in fromDriver and toDriver when defining a custom type using customType?
None of the examples do this so it's not clear how/if this is possible?
11 replies