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

    Function getPriceSeries

    • Read a single price-history series by its id. The id is the product's identity key for the base row, or ${productKey}::${variantKey} for a variant row. Returns undefined when no series exists yet (the first time a product/variant is seen) or when the read fails.

      Parameters

      • id: string

        The series id.

      Returns Promise<undefined | PriceHistoryEntry>

      The stored PriceHistoryEntry, or undefined when absent.

      const series = await getPriceSeries("3f9c2a…");
      const last = series?.points.at(-1)?.usd; // most recent USD price
      export async function getPriceSeries(id: string): Promise<PriceHistoryEntry | undefined> {
      try {
      const db = await getDB();
      return await db.get(IDB_STORE.PRICE_HISTORY, id);
      } catch (error) {
      logger.error('Failed to get price series from IndexedDB', { error });
      return undefined;
      }
      }