TIMESTAMPTZ is returned as string instead of Date object

It seems that drizzle upon initialization (re-)sets pg-types handling of dates. Usually pg-types and thus node-postgres converts TIMESTAMP, TIMESTAMPTZ and other related data base types automatically to a JS date object. I tried Drizzle with the node-postgres driver and it didn't seem to work, dates were simply strings. I figured that Drizzle resets the default type convertes upon initialization (see picture). I was wondering why that is. And is that simply a me problem or did anyone also find TIMESTAMP being returned as string when using node-postgres?
No description
4 Replies
MAST
MAST16mo ago
I don't know how your schema is defined but for the timestamp column you can define a mode that tells it if it should return a date or string like this:
created_at: timestamp('created_at', { withTimezone: true, mode: 'date' })
created_at: timestamp('created_at', { withTimezone: true, mode: 'date' })
ptrxyz
ptrxyzOP16mo ago
oh nice can I have that the default for drizzel-kit's introspect?
MAST
MAST16mo ago
I don't think there's an option for it, unfortunately
ptrxyz
ptrxyzOP16mo ago
oh that's a pity. I find that there are not too many options after all. thanks anyway
Want results from more Discord servers?
Add your server