How to create a reusable query that can receive different select values?

I have a query with a lot of filters and ordering logic that I want to reuse but with different selects across a few endpoints, something like this:
  getProjectQuery<T extends SelectedFields>(select: T, filters: ProjectFilters) {
      db
        .select(select)
        .from(project)
        .leftJoin(customer, eq(customer.id, project.customerId))
        .where(...filters);
  }

But I don't know how to type the select correctly.

When I do this anything after the left join becomes a type error:
image.png
Was this page helpful?