ChemPal Documentation - v1.6.0
    Preparing search index...

    Function getSearchHistory

    • Reads every search-history entry, newest first.

      Returns Promise<SearchHistoryEntry[]>

      History entries sorted by descending timestamp, or [] on failure.

      const history = await getSearchHistory(); // => [{ query: "acetone", timestamp: 172… }]
      
      export async function getSearchHistory(): Promise<SearchHistoryEntry[]> {
      try {
      const db = await getDB();
      const all = await db.getAll(IDB_STORE.SEARCH_HISTORY);
      // Return sorted newest-first
      return all.sort((a, b) => b.timestamp - a.timestamp);
      } catch (error) {
      logger.error('Failed to get search history from IndexedDB', { error });
      return [];
      }
      }