Drizzle TeamDT
Drizzle Team3y ago
7 replies
miloudi

Using one function to query many tables of same structure

Hello i have many tables (5-6) that have same structure like this
export const speciality = pgTable('speciality', {
    id: serial('id').primaryKey(),
    name: varchar('name', { length: 255 }).notNull()
});

this is what i think is called lookup table, i want a simple query that fetches from one of the tables (based on function arg) and gives out a a simple result, query is simple, no joins or anything, just a limit, is there a way to create a function that does this in a typesafe manner
Was this page helpful?