Skip to content

Export DB throw error. #75

@portguas

Description

@portguas

I'm using absurd-sql in electron.
I export the db like this.

try {
      const db = await getInstance()
      const data = db.export()
      const blob = new Blob([data], { type: 'application/octet-stream' })
      const blobHref = URL.createObjectURL(blob)

      self.postMessage({ action: 'exportedDB', blobHref })
    } catch (error) {
      console.info('sql export error, return ', error)
    }

It got error.

sql export error, return  TypeError: Cannot read properties of undefined (reading 'constructor')
    at readChunks (indexeddb-backend.js:65:20)
    at File.read (indexeddb-backend.js:248:22)
    at Object.read (index.js:101:37)
    at Object.read (sql-wasm.js:151:211)
    at Object.readFile (sql-wasm.js:154:349)
    at c.export (sql-wasm.js:88:238)
    at self.onmessage (instance.ts?type=mod…er_file? [sm]:86:23)

The error caused by const data = db.export()
In indexeddb-backend.js ,the data in undefined.

if (chunk.data.constructor.name !== 'ArrayBuffer') {
     throw new Error('Chunk data is not an ArrayBuffer');
   }

How can i resolve it. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions