What's the right way to get the type of a query?

Hi, I have this

export async function findTicketById(ticketId: string) {
  const ticket = await db.query.ticketsTable.findFirst({
    where: (tickets, { eq }) => eq(tickets.ticketId, ticketId),
    with: {
      assignedTo: true,
      createdBy: true,
      user: true,
    },
  });

  return ticket;
}


and I'm trying to get the type of the ticket that is given back, which has a few additional types due to the "with" statements. Main reason for this is I want to have a function that cleans the response up before i send it back to the frontend and then i also want to be able to get these types over to my frontend repo.

What's the best way to get the type of this query?
Was this page helpful?