As @mrded said, the simplest solution is to use batch operations:
<button onClick={handleExport}>Export</button> <input type="file" onChange={handleImport}/>
function handleExport () { db.allDocs({include_docs: true}, (error, doc) => { if (error) console.error(error); else download( JSON.stringify(doc.rows.map(({doc}) => doc)), 'tracker.db', 'text/plain' ); }); } function handleImport ({target: {files: [file]}}) { if (file) { const reader = new FileReader(); reader.onload = ({target: {result}}) => { db.bulkDocs( JSON.parse(result), {new_edits: false},
Also check the download function.
Igor Sukharev
source share