gilf / angular2-indexeddb

angular2-indexeddb is a library that wraps indexeddb database in an Angular service.
MIT License
88 stars 44 forks source link

memory crash inserting > 200.000 items #30

Closed fdambrosio closed 7 years ago

fdambrosio commented 7 years ago

I have a JSON file with more 200 thousands items. I slice it reducing it in smallest array length, and I iterate calling "db.add". I have a memory crash using Chrome but I haven't problems until 100 thousands items (of course waiting a lot of minutes to complete the insertion). What's the best practice for massive insert?

gilf commented 7 years ago

@fdambrosio I don't think that the current browsers implementation of IndexedDB is suitable for such a big data source. See the answer here for reference.

fdambrosio commented 7 years ago

thanks @gilf, now I've found IDBObjectStore.put() method, it solves problems on bulk data insert. https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/put

gilf commented 7 years ago

@fdambrosio You can use the service's update function which will result in a call for the objectStore put function in the end. I should have called the function put instead of update but now if I'll do that it will result in breaking changes to people who are using the service.