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

    Function getSearchResults

    • Reads the persisted search results. The row is stored under a single "current" key, so this is one read. See getSearchResultsRecord when the originating query is needed too.

      Returns Promise<Product[]>

      The persisted products, or [] when nothing is stored or the read fails.

      const products = await getSearchResults(); // => [{ id: "…", title: "Acetone" }]
      
      export async function getSearchResults(): Promise<Product[]> {
      try {
      const db = await getDB();
      const record = await db.get(IDB_STORE.SEARCH_RESULTS, 'current');
      return record?.data ?? [];
      } catch (error) {
      logger.error('Failed to get search results from IndexedDB', { error });
      return [];
      }
      }