Code review, building a generic DAO for DB ops
Hi all, for my SvelteKit application I was building a generic DAO for common CRUD operations as below
pretty new to Drizzle so was wondering if this approach seems alright, feel like typing could be improved, would really appreciate any guidance.
Cheers!
3 Replies
anyone?
This seems pretty similar to the native query functionality. Is there something I am missing?
This is similar to what I'm doing as far as the generic types extending from
TableWithId
. I'm not using classes though and I'm not always returning the default selection so I have to cast to SelectResult<R, "single", {}>[]
and also sometimes I cannot even pass a table to from()
without casting it as any .from(table as any)
- https://gist.github.com/waynesbrain/8b295a2d359c97ae05fc132e071c9ad5