-
Notifications
You must be signed in to change notification settings - Fork 49
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
Make it runnable in a webworker #172
Comments
use |
The problem is that nanosql is trying to access localstorage while its not available in the webworker. |
I had this issue as well. To get around it you can mock localStorage on the global object in your web worker. Example: self.localStorage = {
getItem: function() {},
setItem: function() {},
removeItem: function() {}
}; It looks like it's using localStorage to store some information about the database version and model hash if you don't supply a version number. It's also storing some information about auto increment if you are using that. At least that's my understanding from looking at this file: https://github.com/ClickSimply/Nano-SQL/blob/master/packages/Core/src/adapters/indexedDB.ts If you aren't using any of these things, the mock above should work. If you do need these things, you'll have to add code to your mock to make it work, keeping in mind that nanosql expects these methods to be synchronous. The indexeddb adapter could probably be modified to use a separate indexeddb database to store these values instead of localStorage. |
Is your feature request related to a problem? Please describe.
I would like to run nSQL in a webworker. This however is not possible due to nanosql referencing to localStorage (when using IndexedDB). LocalStorage is not available in a webworker.
Describe the solution you'd like
Let nanosql no longer reference the localstorage when on IndexedDB
The text was updated successfully, but these errors were encountered: