techfort / LokiJS

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

Sharing Collection Across Application (Web Workers) #885

Closed withintheruins14 closed 3 years ago

withintheruins14 commented 3 years ago

I have one ESM module that exports the Loki db, like so:

import Loki from 'lokijs';
export default new Loki('n2x', { autosave: true, env: 'BROWSER' });

I have two separate ESM modules that are loaded as web workers. They both import the db module above.

I add items to the collection in one of the workers and I can see that there is data in the collection

When I retrieve that collection in the other worker there is no data.

Should I expect this to work? Happy to post the code if anyone could please help me. Thanks!