Dexie.js: Export of empty table fails with error

Created on 26 Nov 2018  路  7Comments  路  Source: dfahlander/Dexie.js

Thanks so much for creating an optimized import/export addon! In testing it with my application's dataset, which can contain empty tables, I ran across an error trying to access a property on undefined from https://github.com/dfahlander/Dexie.js/blob/master/addons/dexie-export-import/src/export.ts#L143 ("TypeError: Cannot convert undefined or null to object")

I'd be happy to make a PR for this, but I'm curious how you'd best like to handle it. Defaulting to an empty object as the first argument to Dexie.getByKeyPath seems acceptable, but I wanted to check to see if you'd prefer a more elegant approach.

All 7 comments

Thanks for the report! I think checking values.length > 0 would be nice, something like:

lastKey = values.length > 0 ?
  Dexie.getByKeyPath(...) :
  null;

Maybe do the same on line 166 for clarity.

Agreed, will make a PR!

@dfahlander does not seems like this feature was ever released. Any plans to get that out?
I checked with version 1.0.0-alpha.8 but is not there.

Sorry, I've just released 3.0.0-alpha.7 which contains all latest changes.

https://www.npmjs.com/package/dexie-export-import

Here there is still 1.0.0. Where did you release this new version?

Sorry. Released dexie only. Will fix! :)

Now, published it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ibc picture ibc  路  3Comments

dmlzj picture dmlzj  路  3Comments

xavibonell picture xavibonell  路  4Comments

kamleshchandnani picture kamleshchandnani  路  4Comments

nezcich picture nezcich  路  3Comments