Properly inferring Prepared Statement Return Type when executing a query
Hi everyone ๐
I'm working on a SvelteKit project with Drizzle ORM and i'm trying to extract some of the queries to prepared statements.
There's probably something i'm doing wrong, yet when i execute the prepared statement in my codebase - i'm loosing the inferred model return type.
Meaning,
const data = await ps.execute()
| ps.all()
| ps.execute({ ph: 'ph'})
return type is unknown
.
I'm declaring and exporting the prepared statements like this:
then importing and using them in my application like this:
and i get 'getAllAccounts' is of type 'unknown'
| 'getAccount' is of type 'unknown'
when trying to access the data.
trying to set the var name to the inferred model type (like const getaAllAccounts: Account[]
didn't work either...Type 'unknown' is not assignable to...
).
Any ideas?
Thanks in adance๐2 Replies