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

Suggested pattern for usage with Dexie (or IndexedDB) #98

Open
dskvr opened this issue Jul 16, 2024 · 0 comments
Open

Suggested pattern for usage with Dexie (or IndexedDB) #98

dskvr opened this issue Jul 16, 2024 · 0 comments

Comments

@dskvr
Copy link

dskvr commented Jul 16, 2024

Does anyone have experience or an example to share of how to implement @square/svelte-store on an IndexedDB that has multiple tables and indices?

From what I can gather, to implement IndexedDB using this library, one would not just create an INDEXED_DB StorageType but rather a StorageType for each individual table. Additionally, due to the restrictive interface of the getter/setter/deleter functions, if there were multiple indices, there would need to be a StorageType for each desired index within a table. TABLE1_KEYPATH1 ... TABLE1_KEYPATH2 ... etc, which other than having some maintenance issues, would likely face some performance issues as well (potential for duplicate, dereferenced data)

For example with Dexie, where a "key" can be a object

Interface for Table.get()

table.get(primaryKey): Promise
table.get({keyPath1: value1, keyPath2: value2, ...}): Promise

From what I can see, this is not compatible with the existing interfaces of getStorageItem/setStorageItem/deleteStorageItem, forcing what might be considered an anti-pattern on an implementation (storage types for each index as mentioned above, or wrap this library to JSON.stringify arguments and then JSON.parse the arguments in the functions)

Please let me know if I am missing something.

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

No branches or pull requests

1 participant