IndexedDB implementation via PouchDB and DexieJS - works on localhost but not on the production build

27 Views Asked by At

I am building a nextJS app that needs to dump API data fetched from the BE on the initial load to the indexedDB. Data set is around 100 rows (~500kb).

Both approaches (PouchDB & DexieJS) works well on the localhost, behaving as expected, however, once I deploy the app and mask the actual domain to it, only the initial DB initialisation happens, which shows the bast setup of pouchDB or DexieJS db setup in the browser storage tab. However, I don't see the actual API data being stored on the production built. Both approaches are giving me exact same behaviors hence why I am considering if something other than library scope is causing this in the production builds.

For PouchDB, I am using following snippets to read and write the transactions:

Write Operation

    await pouchDB.bulkDocs(encrypted);

Read Operation

    (async () => {
      await pouchDB.allDocs({
        include_docs: true,
        limit: 5,
      }).then((res) => {
        console.log("RES", res);
        setDataFromLocal(res);
      }).catch((err) => {
        console.log('err', err);
      });
    })();

For DexieJS, I am using following snippets to read and write the transactions:

Write Operation

    db.transaction('readwrite', db.table, async() => {
      return await db.table.bulkPut(encrypted).then(() => alert('success')).catch((err) => alert(JSON.stringify(err)));
    });

Read Operation

const itemsFromLocal = useLiveQuery(() => db.table.toArray());
0

There are 0 best solutions below