Infer date values in jsonb column as Date object

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

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] ]
    }
  ]
}
Was this page helpful?