How can I get a type from SelectedFields<MySqlColumn, Table>?
Hi guys sorry to bother buy I'm trying to build a Repository Pattern with Drizzle and I stuck with a type.
The interface with I came up is
This is working fine but my problem is that the type of allUsers is
and I'm trying to get something like
So i want to do something like InferSelectModel<S> but I can't and I'm not sure how to do it, any hint on how can i solve it o what documentation can i read to understand a bit more and solve it?
Thanks
11 Replies
You'll have to use one of the internal drizzle types
In this specific case, since you'll be selecting only single tables you could do it this way:
that looks really good but I am no able to import that type on my code, i'm using drizzle-orm 0.28.6 how can i import that type?
https://github.com/drizzle-team/drizzle-orm/blob/a7dc7e8bbdc3784f67ff32ce39bee3283f080751/drizzle-orm/src/query-builders/select.types.ts#L37 i think this is the type buy im not sure how ti import i
GitHub
drizzle-orm/drizzle-orm/src/query-builders/select.types.ts at a7dc7...
TypeScript ORM that feels like writing SQL. Contribute to drizzle-team/drizzle-orm development by creating an account on GitHub.
how to import it in my code
i think is a current bug https://github.com/drizzle-team/drizzle-orm/issues/637
GitHub
[BUG]: Missing proper export for SelectResult · Issue #637 · drizzl...
What version of drizzle-orm are you using? 0.26.1 What version of drizzle-kit are you using? 0.18.1 Describe the Bug SelectResult is currently not exported from drizzle-orm/mysql-core or drizzle-or...
import { SelectResult } from "drizzle-orm/query-builders/select.types";
That will get you out of the pinch while the issue is being resolvedyes i tried that but is now working for me
Yeah, it's a bug
A workaround would be to just define the the type:
* This is a workaround, use it at your own risk
looks like the type is not exported correctly. Could you create an issue on GH for that?
hi @Dan Kochetov the issue is already created by another user https://github.com/drizzle-team/drizzle-orm/issues/637
GitHub
[BUG]: Missing proper export for SelectResult · Issue #637 · drizzl...
What version of drizzle-orm are you using? 0.26.1 What version of drizzle-kit are you using? 0.18.1 Describe the Bug SelectResult is currently not exported from drizzle-orm/mysql-core or drizzle-or...