paldepind / synceddb

Makes it easy to write offline-first applications with realtime syncing and server side persistence.
MIT License
411 stars 34 forks source link

What makes synceddb a good offline-first database? #47

Open sebastianmacias opened 6 years ago

sebastianmacias commented 6 years ago

I'm in the process of evaluating multiple offline-first databases and I just found out about synceddb. I'm very excited to see other alternatives to gun.js (which I'm currently using and recommending for a few projects).

If you don't mind taking the time to answer a few questions, I would love to know:

Thanks for all the good work so far and also thanks in advance for taking the time to answering these questions. I'm planning to run a few test in the next weeks.

nevf commented 6 years ago

@sebastianmacias I am not using synceddb or gun.js however this topic is also of great interest to me.

I have been keeping an eye on Gun for a while and I struggle with it being called a "database". AFAIK it does not use indexes, has no query language capabilities, is primarily in-memory and it's replication has been questioned (search Redit). Also when I tried it offline, synchronization failed when it went back online. There is an old Github issue on this, which I think still hasn't been addressed.

To me Gun.js is more like an in memory mesh/graph with replication capabilities.

You might want to look at https://www.npmjs.com/package/dexie-syncable which is where I think I'll head as I already use Dexie.js in my Web app Clibu.

If you you are planning on writing up your evaluation I'd certainly be interested in seeing that.

paldepind commented 6 years ago

I'm not familiar with Gun.js.

One of the distinguishing features of SyncedDB is that it attempts to be a very lightweight wrapper around IndexedDB. It's essentially IndexedDB + migrations + promises + syncing.

can you query the data even if the server is offline?

how about inserts and updates when the server is offline?

Everything happens offline first. Queries, inserts, updates, etc. Afterwards, if there is a connection to the backend, does the syncing happen.

how would they synchronize later on and how are conflicts handled?

Conflicts are handled by invoking a user-supplied callback. This callback can be used to implement the conflict handling that is appropriate for the application. An example of this can be found in the counters example.

nevf commented 6 years ago

@paldepind Thanks for replying to @sebastianmacias

A few issues I personally see with Synceddb:

Dexie.js handles both of these cases.

sebastianmacias commented 6 years ago

Thanks @nevf and @paldepind for your feedback. Dexie.js Iooks interesting as well. I plan to implement a basic app with gun.js, synceddb and Dexie.js and will publish what I find along with the source code.

amark commented 6 years ago

@paldepind nice work! :) Keep it up. We need more people create better databases.

Wanted to reply to @nevf 's concerns:

nevf commented 6 years ago

@amark Thanks for taking the time to respond.

The Github issue is https://github.com/amark/gun/issues/259 which dates back to Nov 1, 2016 and is still open. The initial post is from PsychoLlama, however I reported this and he raised the issue.

For my use case storing all data in memory won't work because it can get big and would waist resources. I also need composite indexes and multiple indexes on a document (JSON Data) which is all doable with IndexedDB and MongoDB etc.

I have recently looked at the Gun docs and it is good see information on Conflict Resolution etc. I don't think that existed at the time of the Reddit thread.

Jaikant commented 6 years ago

@sebastianmacias can you share your findings between these wonderful options made by these fantastic ppl 💯 How much of an issue is #22 ?

sebastianmacias commented 6 years ago

Hi @Jaikant sure, these are my non scientific thoughts about about the libraries:

Gun.js

Pros:

Cons:

Dexie.js

Pros:

Cons:

Lovefield

Pros:

Cons:

Nano-SQL

Pros:

Cons: