Skip to content

BeechCMS


BeechCMS / @beechcms/core / ISearchRepository

Interface: ISearchRepository ​

Read-only contract for the global FTS5 search route.

Implementations encapsulate the UNION ALL query that fans out across all fts_<seed> virtual tables. The route handler stays free of D1 and only shapes the final response.

Methods ​

count() ​

count(options, seeds): Promise<SearchCountResult>

Runs the count variant of the FTS query to support the total field in the search response. Called in parallel with search() by the route handler with the same filter inputs but without limit/cursor. An EMPTY_QUERY resolves to { total: 0 } rather than throwing.

Parameters ​

options ​

Omit<SearchQueryOptions, "limit" | "cursor">

seeds ​

Seed[]

Returns ​

Promise<SearchCountResult>


search(options, seeds): Promise<SearchResultRow[]>

Executes a UNION ALL full-text search across all FTS-enabled seed tables. Returns at most options.limit + 1 rows so the caller can detect hasMore without a separate count query for the cursor case. A query with no usable terms (EMPTY_QUERY from buildFtsQuery) must resolve to an empty array rather than throw, so the route handler never returns a 500 for it.

Parameters ​

options ​

SearchQueryOptions

seeds ​

Seed[]

Returns ​

Promise<SearchResultRow[]>