array of number returning strings

Hey, I've defined an array of number in my schema:
price: numeric('price', { precision: 10 }).array()
price: numeric('price', { precision: 10 }).array()
The problem is that when I retrieve the value, it's actually typed as an array of string: price: string[] How comes? How can I get the right type? (number[]) When I hover on the column declaration on my schema, it shows this: see capture Why is the data: string[]?
No description
2 Replies
Janick
JanickOP5mo ago
The solution was to add this to my schema definition:
price: numeric('price', { precision: 10, scale: 0 })
.array()
.$type<number[]>(),
price: numeric('price', { precision: 10, scale: 0 })
.array()
.$type<number[]>(),
Alex DB
Alex DB2mo ago
I've just run into that, wanted to add that the order is important, you can't have $type before array or it won't properly type it.
Want results from more Discord servers?
Add your server