Conversation
… returns "undefined" (keep compatibility) or "true". Because IndexedDB is limited on filtering, I had to use iterate and manually check each item with custom filters. But I still need to limit the quantity of records returned, so I don't iterate the whole store, I know that there is the param "limit" the problem is that IDBWrapper doesn't know how many records passed my filter. To solve this, I changed the "onItem" function to return a boolean and increment "recordCount" only if it returns "undefined" (keep compatibility) or "true".
…n array of stores. Creation of a class called "Store" which contains the specific attributes of a store. Main class changed to receive the param dbName and an array of store params to create each store inside the DB. With these changes the user is able to create one DB with multiple stores. Tests changed to comply with the new behavior.
|
Thanks for the PR! Wow, that's quite some work, awesome :) I'll need some time to go through this, but one question upfront: What was your reasoning behind this change? I mean, what are the benefits of this architecture? |
|
I am implementing an app that has some parts that need to work offline, that's the reason I started using IndexedDB and looked for a nice lib that simplifies the complicated original API and found IDBWrapper ;) Thanks for taking the time to analyze my PRs :D |
I refactored the way IDBWrapper works with stores.
Instead of creating one DB for each store, I think the right way is to create one DB with multiple stores.
My mains changes consist of receiving the name of the DB and an array of params to create the stores.
To accomplish this, I created an internal class called Store to group the store handling that was directly in the main class.
The result is an object created just like before, but instead of using it like: idb.put, now it is idb.store1.put, for example.
The refactor is extensive and I might have left something behind, but I ask you to please consider merging to your repository.
If you find anything that needs to be changed, just tell me and I can do it :)