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
4 Replies
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']
The two solutions don't work
The selectedFields is typed as PgColumn and not columnType
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-ormIt 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