or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-9/

Database View Query Helper

A utility for fetching records from a database view while honoring the view's filters, grouping, and search behavior.

Capabilities

Apply view-defined filters

  • Fetching a view returns only the records visible in that view; entries failing the view's filters are excluded. @test

Preserve grouping and ordering

  • Results are grouped using the view's grouping rules, include an uncategorized bucket when grouping data is missing, and keep the group order defined by the view. @test

Search within the view

  • Providing search text narrows results using the view's search behavior while keeping group counts and ordering consistent with the filtered data. @test

Implementation

@generates

API

export interface QueryOptions {
  databaseId: string;
  viewId: string;
  authToken: string;
  search?: string;
  timeZone?: string;
  pageSize?: number;
}

export interface GroupBucket {
  name: string | null;
  order: number;
  items: Array<{ id: string; title: string; [key: string]: unknown }>;
  count: number;
}

export interface ViewQueryResult {
  groups: GroupBucket[];
  total: number;
}

export async function queryDatabaseView(options: QueryOptions): Promise<ViewQueryResult>;

Dependencies { .dependencies }

notion-client { .dependency }

Queries database views with server-side filters, grouping, and search. @satisfied-by