© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•8mo ago•
1 reply
mael

Is there a way to properly type a "generic query"

Is there a way to properly type a "generic query" with drizzle, rather than trying to duck-type it like this

export async function paginateWithCursor<
  T,
  TQuery extends {
    where: (condition: SQL) => TQuery;
    orderBy: (...fields: SQL[]) => TQuery;
    limit: (limit: number) => TQuery;
  } & Promise<T[]>,
>(
  baseQuery: TQuery,
  cursorConfig: CursorConfig,
  options?: CursorPaginationOptions,
): Promise<CursorPaginationResult<T>> {
export async function paginateWithCursor<
  T,
  TQuery extends {
    where: (condition: SQL) => TQuery;
    orderBy: (...fields: SQL[]) => TQuery;
    limit: (limit: number) => TQuery;
  } & Promise<T[]>,
>(
  baseQuery: TQuery,
  cursorConfig: CursorConfig,
  options?: CursorPaginationOptions,
): Promise<CursorPaginationResult<T>> {
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

Is there a way to save the generated response Type from a query?
Drizzle TeamDTDrizzle Team / help
3y ago
Is there a way to create this query in drizzle?
Drizzle TeamDTDrizzle Team / help
16mo ago
Is there a smarter way to use optional query values
Drizzle TeamDTDrizzle Team / help
3y ago
Is there a way to have a query- or transaction-level hook?
Drizzle TeamDTDrizzle Team / help
3y ago