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

    Function putChemicalDb

    • Replaces the cached OSHA OBIS chemical dataset.

      Parameters

      • chemicals: OshaChemical[]

        The slimmed chemical records to store.

      • fetchedAt: number

        Epoch milliseconds the dataset was downloaded; drives TTL expiry.

      Returns Promise<void>

      Resolves once the write completes; errors are logged, not thrown.

      await putChemicalDb(records, Date.now());
      
      export async function putChemicalDb(chemicals: OshaChemical[], fetchedAt: number): Promise<void> {
      try {
      const db = await getDB();
      await db.put(IDB_STORE.CHEMICAL_DB, { id: CHEMICAL_DB_KEY, fetchedAt, chemicals });
      } catch (error) {
      logger.error(`Failed to write chemical DB to IndexedDB: ${getErrorMessage(error)}`, { error });
      }
      }