techfort / LokiJS

javascript embeddable / in-memory database
http:/techfort.github.io/LokiJS
MIT License
6.74k stars 482 forks source link

Error: this collection cannot be loaded lazily #926

Open tomkennedy22 opened 1 year ago

tomkennedy22 commented 1 year ago

Hey all, running in to a problem, would love some guidance.

I'm using the incremental indexeddb adapter created by @radex . I've had success with Vanilla Loki - as well as with the normal IndexedDB adapter, but really like the look of the Incremental Adapter.

I have about 20 collections, of varying sizes. All of them have the following settings:

  1. a proto define to inflate on load
  2. lazyLoad: true
  3. clone: true
  4. clone_method: shallow-assign
  5. The collection name is in the adapter options list for "lazyCollections".

I've tried this setup with all of the lazy settings turned off - both in individual collections and the adapter definition.

I'm at a bit of a loss on how to proceed. I've combed through all of the code that leads to that line, but can't figure out how to get my data loaded from idb for some of my collections. Notably, not all collections have this issue.

Thanks!

radex commented 1 year ago

@tomkennedy22 I can't answer the problem off the top of my head, but my Loki usage is all here: https://github.com/Nozbe/WatermelonDB/blob/master/src/adapters/lokijs/worker/DatabaseDriver.js (and generally in the lokijs) catalog - maybe that helps you somehow in understanding how I use IncrementalIndexedDB

tomkennedy22 commented 1 year ago

Thanks for the response @radex. I've read through WatermelonDB, and I think it makes sense how you approach it. It might take me a few days/weeks to re-visit my code and figure out the gap, as I tabled the incremental-idb change for the time being. Thanks for the help! I'll reach out again if needed.