Chev
Chev
Explore posts from servers
DTDrizzle Team
Created by Chev on 2/5/2025 in #help
refine and createInsertSchema
Solved with the following:
export const newTestSchema = createInsertSchema(Test, {
startedAt: z.date(),
completedAt: z.date().optional()
})
.omit({
id: true,
})
.refine(
({ startedAt, completedAt }) => {
const now = new Date()
if (startedAt > now) return false

if (completedAt == null) return true

return completedAt <= now && completedAt > startedAt
},
() => ({
path: ['startedAt', 'completedAt'],
message: 'completed date at must be after started date'
})
)
export const newTestSchema = createInsertSchema(Test, {
startedAt: z.date(),
completedAt: z.date().optional()
})
.omit({
id: true,
})
.refine(
({ startedAt, completedAt }) => {
const now = new Date()
if (startedAt > now) return false

if (completedAt == null) return true

return completedAt <= now && completedAt > startedAt
},
() => ({
path: ['startedAt', 'completedAt'],
message: 'completed date at must be after started date'
})
)
2 replies
HHono
Created by Chev on 8/27/2024 in #help
tRPC subscriptions throw net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) with httpSubscriptionLink
Nobody experiencing the same or using trpc?
7 replies
DTDrizzle Team
Created by function on 1/30/2025 in #help
Get all authors with latest book
share what you have so far
11 replies
DTDrizzle Team
Created by Phantom on 1/4/2025 in #help
Drizzle not creating enum
you need include the enum in your exported schema
export const status = pgEnum('status', [
'created',
'generating',
'generated',
'error',
]);

export const Widget = pgTable('widget', {
status: status().notNull().default('created'),
...
export const status = pgEnum('status', [
'created',
'generating',
'generated',
'error',
]);

export const Widget = pgTable('widget', {
status: status().notNull().default('created'),
...
20 replies