From 295a2d9f63487fba251998188d6401a3328917f4 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 23 May 2025 11:06:37 -0600 Subject: [PATCH] don't export 0s for undefined values! --- src/components/DataExportSection.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/DataExportSection.vue b/src/components/DataExportSection.vue index 647beb19..9bdc1a9a 100644 --- a/src/components/DataExportSection.vue +++ b/src/components/DataExportSection.vue @@ -131,7 +131,20 @@ export default class DataExportSection extends Vue { */ public async exportDatabase() { try { - const blob = await db.export({ prettyJson: true }); + const blob = await db.export({ + prettyJson: true, + transform: (table, value, key) => { + if (table === "contacts") { + // Dexie inserts a number 0 when some are undefined, so we need to totally remove them. + Object.keys(value).forEach(prop => { + if (value[prop] === undefined) { + delete value[prop]; + } + }); + } + return { value, key }; + }, + }); const fileName = `${db.name}-backup.json`; if (this.platformCapabilities.hasFileDownload) {