romeerez/orchid-orm

type bug: findBy throws TypeError with undefined

Closed this issue · 3 comments

db.xxx.findBy({ userId: undefined }) throws a TypeError, but there is no typescript check.

I hope it will show an error on my editor, like find(undefined) does

Could you share your error message and a bit of code around the query?

Because undefined values are ignored from filtering, so userId: undefined has no effect and it simply takes whatever record it can find. Wondering how you get the TypeError.

No TS error for this case is not something that can be or should be fixed, because findBy expects a partial record, and { user: undefined } is a valid partial record, undefineds are being ignored as if they weren't provided at all.

Sorry, romeerez, I found the error is from my repo which transform() the return value, but I assume it returns an array, not handle gracefully for find result.