© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
24 replies
ak4zh

Infer date values in jsonb column as Date object

I used
$types<>()
$types<>()
to provide the type for my
jsonb
jsonb
column but the returned value is date string not a js
Date
Date
object.

type InvoiceSchema = {
    invoiceNumber: string;
    invoiceDate: Date;
    items: {
        name: string;
    }[];
    value?: number;
}
export const myTable = pgTable('my_table', {
  invoices: jsonb("invoices").$type<InvoiceSchema[]>(),
})
type InvoiceSchema = {
    invoiceNumber: string;
    invoiceDate: Date;
    items: {
        name: string;
    }[];
    value?: number;
}
export const myTable = pgTable('my_table', {
  invoices: jsonb("invoices").$type<InvoiceSchema[]>(),
})

Output Data
{
invoices : [
    {
      invoiceNumber: '3432423',
      invoiceDate: '2024-07-13T00:00:00.000Z',
      value: null,
      items: [ [Object] ]
    }
  ]
}
{
invoices : [
    {
      invoiceNumber: '3432423',
      invoiceDate: '2024-07-13T00:00:00.000Z',
      value: null,
      items: [ [Object] ]
    }
  ]
}
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle Studio jsonb column showing [object Object]
Drizzle TeamDTDrizzle Team / help
7mo ago
Full-text search on jsonb column
Drizzle TeamDTDrizzle Team / help
3y ago
define a jsonb column with `{}` as default value does not work
Drizzle TeamDTDrizzle Team / help
3y ago
date column not being returned as string by drizzle
Drizzle TeamDTDrizzle Team / help
3y ago