Drizzle always says data exists even tho it can be undefined in ts.
This is my service.
Then i use it like this:
If i hover over
renter
it gives the data type without undefined
being a possibility.
This causes for me to forget to check if the data exists or not because linter does not warn.
I think im doing something wrong would like your help5 Replies
Not a definitive solution, but you can do this:
Hmm. looks very hacky
There is no other better way? I mean is it a very specific thing that I want?
There is no other way, since it's not possible for Drizzle to know at the type level how many rows will be returned by a query
Ok the way you proposed works great. But is it really "standard" way to use drizzle orm?
Or should i just leave it as array and have no typesafety and just check the length of array then select the first item?
We are indifferent as to the use of the
then
method, the point of Drizzle is for it to be flexible and suit your needs. If you're in a team and said team doesn't mind then you can absolutely feel free to use it