ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamโ€ข3y agoโ€ข
4 replies
Paul | Blue

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;
}
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?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

What's the best way to query my db?
Drizzle TeamDTDrizzle Team / help
2y ago
How to get the return Type of a query with relations?
Drizzle TeamDTDrizzle Team / help
3y ago
Best way to get the type of a where condition dynamically
Drizzle TeamDTDrizzle Team / help
3y ago
Is there a way to properly type a "generic query"
Drizzle TeamDTDrizzle Team / help
8mo ago