Comments (12)
expect
from watermelondb.
Out of interest, do you have any insight into the relative performance of the LokiJS vs SQLite adaptors?
Not formally / in numbers. LokiJS is very fast for computing queries, but it doesn't have true lazy loading. So if you have a 50MB database, it needs to be loaded into memory at app launch which may be slow on some devices. SQLite doesn't have that problem
from watermelondb.
We’ll be happy to accept a contribution that adds an Electron adapter :)
from watermelondb.
We would be interested in implementing this. We are building an offline-first electron app with React, and we'd like to bind the state to a local SQLite database and sync to the cloud.
We've had a look through the source code and this is our rough understanding of what needs to be done:
In adapters/sqlite/index.js
, you have the bridge to the native code with the line const Native: NativeBridgeType = NativeModules.DatabaseBridge
. For electron, we'd need to implement this "DatabaseBridge" interface via nodejs, using something like node-sqlite3 to talk to the database. (We'll also need to modify this file to abstract out the calls to react-native, maybe as a separate adaptor or just an argument to the SQLiteAdapterOptions
.)
We also need to think about how to do the multi-threading, as we do not want the database calls running inside the renderer process. Possibly we can re-use the concepts from the LokiJS implementation via web workers, although workers are still experimental for node. Another would be to run the queries as part of a separate node server over node-ipc. Maybe we just provide the interface and it's up to the user to decide.
Are we roughly along the right lines?
from watermelondb.
Closing this issue as it seems no one is working on this currently. Please let me know if someone wants to implement this - I can give guidance
from watermelondb.
@davidkell Yep, that all sounds correct!
from watermelondb.
@davidkell Is there any progress ? We have a react-native app and a electron app, so we are also interesting in making WatermelonDB support electron
from watermelondb.
@endpress I would very much welcome Electron support, so if @davidkell hasn't released any code, I highly encourage you @endpress to contribute :) The vast, vast, majority of work is done - we only need to hook up electron sqlite to watermelon's sqliteadpter
from watermelondb.
@endpress Yes, please go ahead and contribute!
From our end, we've been using the LokiJS/IndexedDB adaptor in the Electron app, and this is working well.
We'll probably hold off writing the SQLite version until there's a compelling advantage to doing it for us. To be honest, I'm not actually sure what this will be as the LokiJS adaptor is doing a great job, but probably performance or access to raw SQL.
Note that for LokisJS adaptor in electron, you need to enable the nodeIntegrationInWorker: true
for your renderer process.
@radex Out of interest, do you have any insight into the relative performance of the LokiJS vs SQLite adaptors?
from watermelondb.
Someone has a Proof Of Concept ?
from watermelondb.
Any news?
from watermelondb.
@radex In my case I'll have to use SQLite adapter because I need to a SQLite plugins (word spliting) to do full text search, plus the db size could be huge, with SQLite a 2-4G db still works fine
from watermelondb.
Related Issues (20)
- Is it possible to execute multiple queries in a single statement ? HOT 1
- Module '"@nozbe/watermelondb/decorators"' has no exported member 'experimentalFailsafe'.
- "Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome"
- SyncPullStrategy should associate with table instead of sync
- TimeStamp HOT 2
- Local Storage API - Add support for db.localstorage.key() to fetch all key at runtime
- [question] How to install extensions
- Web Bundling failed
- TypeError: Super expression must either be null or a function HOT 2
- Can we get current migration versions like fromVersion and toVersion
- Different between using `@lazy` decorator vs getter?
- Support for Expo SDK50 HOT 1
- Error: [withObservable] Value passed to withObservables doesn't appear to be observable. See console for details
- Observer with pagination not working
- Unable to resolve module ./internal/operators/timeout from E:\eventual-mvp-app\node_modules\rxjs\dist\cjs\index.js:
- Installation guide HOT 1
- Sync pull HOT 1
- Unable to run between query Because number field in schema treated as string in SQLite DB HOT 2
- Unable to use sortBy option for joining table with use of clause HOT 1
- Unable to push sync TypeError: Cannot read property 'type' of undefined at _setRaw HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watermelondb.