idbexport
v1.0.0
Published
Simple indexedDB exporter
Downloads
11
Readme
IdbExport
Utility functions for exporting (and re-importing) a whole indexedDB database. It's inspired from indexeddb-export-import but is realised in typescript and is Promise based.
As for now, Date type serialization and deserialization is supported.
Example usage:
import * as idbExport from 'idbexport'
// Export
const sourceDB = await openDB('sourceDB')
const exportedString = await idbExport.exportToJSONString(sourceDB)
// Import back
const db = await openDB('targetDB')
await idbExport.importJSONString(targetDB, exportedString)
exportToJSONString(db)
Export provided database to a json string.
db: IDBDatabase
return a Promise
importJSONString(db, jsonString)
Import a previously created json string into provided database.
db: IDBDatabase
jsonString: string
return a Promise<void[]>
clearDatabase(db)
Clear provided database
db: IDBDatabase
return a Promise<void[]>