sietecero
sietecero
DTDrizzle Team
Created by sietecero on 9/6/2023 in #help
getViewColumns function? (similar to getTableColumns)
I discovered a work-around, in case anyone finds it useful:
import { ViewBaseConfig } from 'drizzle-orm'

const viewColumns = myView[ViewBaseConfig].selectedFields
await db.select(viewColumns).from(myView).innerJoin(myTable, eq(myTable.someId, myView.someId))
import { ViewBaseConfig } from 'drizzle-orm'

const viewColumns = myView[ViewBaseConfig].selectedFields
await db.select(viewColumns).from(myView).innerJoin(myTable, eq(myTable.someId, myView.someId))
I tried to translate this logic into a generic getViewColumns() function, but didn't have success.
8 replies
DTDrizzle Team
Created by sietecero on 9/6/2023 in #help
getViewColumns function? (similar to getTableColumns)
Interesting, so looking at view.ts closely, they're basically generating a new pgTable to get the columns for this.columns. Was hoping to not have to list out all the columns already defined in the view. Maybe I'll consider submitting a feature request or PR for this.columns to be made public readonly.
8 replies
DTDrizzle Team
Created by sietecero on 9/6/2023 in #help
getViewColumns function? (similar to getTableColumns)
I'm using the PostgresJS driver.
8 replies