don't export 0s for undefined values!
This commit is contained in:
@@ -131,7 +131,20 @@ export default class DataExportSection extends Vue {
|
|||||||
*/
|
*/
|
||||||
public async exportDatabase() {
|
public async exportDatabase() {
|
||||||
try {
|
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`;
|
const fileName = `${db.name}-backup.json`;
|
||||||
|
|
||||||
if (this.platformCapabilities.hasFileDownload) {
|
if (this.platformCapabilities.hasFileDownload) {
|
||||||
|
|||||||
Reference in New Issue
Block a user