Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to modify data during importing/exporting? #1848

Closed
rayzhao99 opened this issue Dec 13, 2023 · 5 comments
Closed

Is it possible to modify data during importing/exporting? #1848

rayzhao99 opened this issue Dec 13, 2023 · 5 comments
Labels

Comments

@rayzhao99
Copy link

When importing/exporting data with the dexie-export-import (https://dexie.org/docs/ExportImport/dexie-export-import), it is possible to filter unwanted data. But, can we modify/change data yet?

A typical scenario (at least to us only) is to change the primary/foreign keys of the data. So when importing into an existed db, conflicts can be avoided.

It would also be appreciated if the filtering & modification can be fulfuled within one callback. For example, current filter() callback could be upgraded to support a similar behavior to the Collection.modify(), so the in-param of value could be modified then.

@dfahlander
Copy link
Collaborator

That's a nice idea, but unfortunately not possible with the current version.

Would a new transform callback be ok? It would have to support both inbound and outbound tables. One suggestion would be to let the optional transform callback return { value } for inbound keys and {key, value} for outbound keys.

image

@rayzhao99
Copy link
Author

rayzhao99 commented Dec 13, 2023

Sure, transform callback would also work for our cases.

So, how to filter & transform together during one importing/exporting? Providing the two callbacks simultaneously? Maybe it could be fulfiled by allowing transform to return falsy, which means the in-param of value is unwanted and should be omitted?

@dfahlander
Copy link
Collaborator

I briefly created a PR for a proposal to add transform to export and import. Should add a unit test also. Change suggestions and additional changes welcome. A unit test is still missing for it.

@rayzhao99
Copy link
Author

Great! Thank you for a so quick response:)

@dfahlander
Copy link
Collaborator

[email protected] released recently with the transform option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants