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

Add option to indexedDB to store object instead of string #158

Open
Viatorus opened this issue Oct 28, 2018 · 2 comments
Open

Add option to indexedDB to store object instead of string #158

Viatorus opened this issue Oct 28, 2018 · 2 comments

Comments

@Viatorus
Copy link
Member

Viatorus commented Oct 28, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/LokiJS-Forge/LokiDB/blob/master/CONTRIBUTING.md#question

Current behavior

IndexedDB stores the database as a JSON string.

Expected behavior

IndexedDB stores the database as an object. Can be enabled via an option.

What is the motivation/use case for changing the behavior?

IndexedDB is an object storage so it can store hole objects (including Date, Map, Blobs etc.).
This would decrease storage space because e.g. Blobs don't have to be serialized using base64.

@obeliskos
Copy link
Collaborator

Hey @Viatorus, sorry I've been out of GitHub loop for a while... hope to get back up to speed soon.

If I recall correctly, I tried that once but it ends up doing a serialization itself (in native code) and I think it was having trouble with our serialize replacers (since those are scoped to js).

It might still be usable in situations where we store data separately from loki (database) and collections... in partitioned situations. Maybe faster as well.

@Viatorus
Copy link
Member Author

Viatorus commented Nov 12, 2018

Hey @obeliskos, no problem. I am also not that active. ;)

Interesting for me is the handling of blobs and TypedArrays independent of the used storage (localStorage, IndexedDB, fs, ...). So we would need another serialization approach than stringifying.

The package https://github.com/localForage/localForage seems to does this by the way.

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

No branches or pull requests

2 participants