angularindexeddbdexie

Dexie Export : Export option: How to filter out a column


https://dexie.org/docs/ExportImport/dexie-export-import https://www.npmjs.com/package/dexie-export-import

We are using dexie and we have an option to export the dexie database (for user support), we are using the dexie-export-import npm package. We have a 10mb limitation to size of the export file and one of the table contains image files...

Currently I'm filtering the entire table. But this table contains other usefull informations. So I'd like to export the tables and only ignore one column. I can't find any exemple on how to do it. All exemple I found are limited to filtering out the entire table.

In resume, I want to export all tables except the column "file" from the table "documents".

    const options: ExportOptions = {
      prettyJson: false,
    };

    options.filter = (table, value, key) => {
      return table !== 'documents';
    };

Thanks in advance!


Solution

  • The latest version of dexie-export-import (version 4.1.1) has a new option transform. We haven't yet documented the new option but it will be added soon to the docs on https://dexie.org/docs/ExportImport/dexie-export-import.

    options.transform = (table, value, key) => {
      if (table === "documents") {
        delete value.file; // Remove "file" property from each row.
      }
      return {value, key};
    };
    

    This is a new feature added by a contributor, so any feedback on this would be apprechiated. Please respond to this question again when you've tried it and confirm whether it solved your case.