how to get generic table type

I tried to use AnyPgTable type to make dynamic function

  async findById(id: number, table: AnyPgTable) {
    const res = await this.db.select().from(table).where(eq(table.id, id));

    return res.at(0);
  }


typescript: Property 'id' does not exist on type 'AnyPgTable'. [2339]


but i need to have id type
all tables have serial id column
  id: serial('id').primaryKey(),
Was this page helpful?