How to get the type from a view with pgView?

The docs does not show how to do it and there is no infer from the view
No description
4 Replies
Angelelz
Angelelz5mo ago
I'm not sure this will work but give it try: InferSelectModel<typeof RegionsView> Otherwise you can use the _ type helper In this case it would be typeof RegionsView['_']['selectedFields']
Júlio
Júlio5mo ago
The two solutions don't work The selectedFields is typed as PgColumn and not columnType
Angelelz
Angelelz5mo ago
I'm on mobile so I can't verify and it's been a while since I worked in drizzle codebase but give this one a try InferModelFromColumns<typeof RegionsView['_']['selectedFields']> You should be able to import that one from drizzle-orm
Júlio
Júlio5mo ago
It works Thanks a lot! I think this could be in the docs! and it should be able to infer the types from pgView directly with .$inferSelect
Want results from more Discord servers?
Add your server