You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm in the process of migrating from PlanetScale to Turso which means I'm now all about SQLite. I need to store decimals. Since SQLite doesn't have decimal support, I'm working on writing a custom column type that can be configured with the number of decimal places via a scale parameter. I'll transform by multiplying/dividing by Math.pow(10, scale) when going to/from the driver.
I did a first pass by using customType, but drizzle-zod turns those columns into any's which is a deal breaker for me.
I took inspiration from this documentation page, and came up with the code below. I don't quite get how all of the config and generics piece together, so I'm looking for guidance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm in the process of migrating from PlanetScale to Turso which means I'm now all about SQLite. I need to store decimals. Since SQLite doesn't have decimal support, I'm working on writing a custom column type that can be configured with the number of decimal places via a
scale
parameter. I'll transform by multiplying/dividing byMath.pow(10, scale)
when going to/from the driver.I took inspiration from this documentation page, and came up with the code below. I don't quite get how all of the config and generics piece together, so I'm looking for guidance.
Beta Was this translation helpful? Give feedback.
All reactions