Coder Social home page Coder Social logo

Can you surport Electron? about watermelondb HOT 12 OPEN

nozbe avatar nozbe commented on May 16, 2024 7
Can you surport Electron?

from watermelondb.

Comments (12)

yee94 avatar yee94 commented on May 16, 2024 3

expect

from watermelondb.

radex avatar radex commented on May 16, 2024 3

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.

radex avatar radex commented on May 16, 2024 1

We’ll be happy to accept a contribution that adds an Electron adapter :)

from watermelondb.

davidkell avatar davidkell commented on May 16, 2024 1

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.

radex avatar radex commented on May 16, 2024

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.

radex avatar radex commented on May 16, 2024

@davidkell Yep, that all sounds correct!

from watermelondb.

endpress avatar endpress commented on May 16, 2024

@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.

radex avatar radex commented on May 16, 2024

@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.

davidkell avatar davidkell commented on May 16, 2024

@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.

castroCrea avatar castroCrea commented on May 16, 2024

Someone has a Proof Of Concept ?

from watermelondb.

dzcpy avatar dzcpy commented on May 16, 2024

Any news?

from watermelondb.

dzcpy avatar dzcpy commented on May 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.