Knex.js Data Type Conversion

253 views Asked by At

I'm using zod, knex.js, Tedious, and js-joda with MS SQL Server. I want to pull a few columns as the appropriate js-joda type. For example, start_date is a date and I want it to be deserialized as a LocalDateTime (and vice versa). I'm just not sure how to get either knex.js or tedious to customize the data type returned, it's always a JS Date, which is inappropriate.

I have the code fairly encapsulated, so currently my best bet feels like just writing my getAll or getOne function with a pipe through my zod type's parse method...but it feels like knex or tedious should have a way to customize a given column's deserializer.

0

There are 0 answers