idbexport

Simple indexedDB exporter

Usage no npm install needed!

<script type="module">
  import idbexport from 'https://cdn.skypack.dev/idbexport';
</script>

README

IdbExport

Actions Status

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[]>