Dexie.js
Dexie.js copied to clipboard
Duplicate DB
Is there a way to duplicate a full database? I can't find how to do.
For now I found a workaround with this (will work once https://github.com/dexie/Dexie.js/pull/1973 is merged)
let duplicateFile = async (fileUuid : string) => {
// I can't find how to duplicate, let's import + export in one go
try {
const db = await new Dexie(fileUuid).open();
const blob = await db.export({prettyJson: true});
await Dexie.import(blob, {
getNewDatabaseName: async (databaseName) => {
return uuidv4();
}
});
} catch (error) {
console.error(''+error);
};
};
not sure if there is a cleaner solution.