The persisted results and query. data is [] and query is undefined
when no row exists (or the row predates the query field).
await getSearchResultsRecord(); // { data: [{ id: "A", ... }], query: "acetone" }
export async function getSearchResultsRecord(): Promise<{ data: Product[]; query?: string }> {
try {
const db = await getDB();
const record = await db.get(IDB_STORE.SEARCH_RESULTS, 'current');
return { data: record?.data ?? [], query: record?.query };
} catch (error) {
logger.error('Failed to get search results record from IndexedDB', { error });
return { data: [] };
}
}
Reads the persisted
search_resultsrow as a whole, returning both the productdataand thequerythat produced it. Use this (instead of getSearchResults) when the caller also needs the originating query — e.g. to rehydrate the results header label so it stays in sync with the persisted results.