Primary key of the entry to update.
The final number of results for that search.
Resolves once the update completes.
await updateSearchHistoryResultCount(1712345678901, 42);
export async function updateSearchHistoryResultCount(
timestamp: number,
count: number,
): Promise<void> {
try {
const db = await getDB();
const tx = db.transaction(IDB_STORE.SEARCH_HISTORY, 'readwrite');
const store = tx.objectStore(IDB_STORE.SEARCH_HISTORY);
const entry = await store.get(timestamp);
if (entry) {
entry.resultCount = count;
await store.put(entry);
}
await tx.done;
} catch (error) {
logger.error('Failed to update search history result count in IndexedDB', { error });
}
}
Backfills the result count on an existing history entry, which is written before the search finishes and so starts out without one. No-ops when the entry is gone (e.g. already evicted).