Feathers: Database syncing for offline-first apps

Created on 16 Mar 2016  ·  20Comments  ·  Source: feathersjs/feathers

FeathersJS seems like a dream come true. But to me it's missing one very essential piece of functionality for building offline-first apps, which is the ability to sync remote and local databases.

Here's a list by kinto that shows all the solutions that offer this kind of syncing functionality. There's already localstorage database, but how would it sync with a remote db? A plugin for CouchDB would make this possible?

Discussion Proposal Question

Most helpful comment

universal (isomorphic) storage is now possible using feathers-levelup, with leveldown (or any other storage backend) in node and level-js in the browser. (thanks @derek-watson!)

keeping the client and server services in sync is left up to the reader, but it should be straightforward with the real-time data events. if you make any progress here, i'd appreciate any re-usable modules, this would be awesome. :smile:

All 20 comments

Yeah, offline first is must have features. I think hook with PouchDB is easy but the thing is I need to learn and have fun with MongoDB (the reason I'm here is MongoDB) so it would be nice if I can sync (is this working via browser?) data from local storage/IndexedDB to MongoDB at remote (like minimongo)

TL;DR I need FeatherJS of this which is not active/buggy and appear outdated/dead

Cheers

@katopz currently we don't support automatic offline mode. It's left up to you currently. We haven't had time to fully flesh it out but I'm pretty sure all the pieces are in place to do this now.

You can use https://github.com/feathersjs/feathers-localstorage on the client and then you should be able to just set up hooks to cache your data after a service returns data or check your localstorage cache before your service hits the server.

We'll hopefully have time to flesh this out over the next month or so. If someone wants to take a crack and submit a PR or a guide that would be awesome! :smile:

We've definitely been thinking about it and building the pieces to do it, just haven't had the time to finish the idea just yet.

universal (isomorphic) storage is now possible using feathers-levelup, with leveldown (or any other storage backend) in node and level-js in the browser. (thanks @derek-watson!)

keeping the client and server services in sync is left up to the reader, but it should be straightforward with the real-time data events. if you make any progress here, i'd appreciate any re-usable modules, this would be awesome. :smile:

Yes! I forgot about levelup! Much :heart: to @derek-watson for that! Technically you can also use NeDB in the browser as well. So there are few different storage engine options.

I think it's going to look more like a recipe than any reusable modules. Maybe some bundled hooks somewhere. If someone makes progress on this before we do please share. Otherwise we'll probably get to this within the next month along with #227.

The leveldb stuff looks great! I think that combined with https://github.com/feathersjs/feathers/issues/256 would be a good base for implementing real offline functionality. The reactive extension will make it much easier to implement things like client-side fall-through caching from which it will hopefully only be a small step to full offline syncing.

I'm working on a Redux middleware to support common offline needs for feathersjs.

Hope to finish the first version soon.

@hnordt Awesome! You might want to take a look at @ahdinosaur's https://github.com/ahdinosaur/feathers-action and @saiichihashimoto's https://github.com/saiichihashimoto/feathers-react-redux for inspiration or maybe to collaborate!

Thank you @ekryski. I'll have a look.

feathers-react-redux needs some work to be really useable, it wasn't planned well. ;-)

+1 for adding support of pouchdb

I would think that using NeDB would be the best offline sync option. It already supports the full query syntax, so you can perform queries to it the same as if you are connected to the server. It's ridiculously performant and has a pluggable storage engine for the browser. Plus, we already have an adapter built for it.

+1 for NeDB solution. I like it for server too.

NeDB or LokiJS or PouchDB?
Compares to NeDB I'd prefer LokiJS since it's even faster and the author had a plan to develop a mongodb fully compatible api.
For PouchDB, it's fully compatible with CouchDB. So using a single command the database can be synced to any CouchDB server.

Loki looks pretty cool.

I recommend LinvoDb https://github.com/Ivshti/linvodb3
It has live queries and scales better than NeDB

I have literally no opinion what the best offline storage solution is as I don't know anything about mobile storage and offline first applications other than doing a lot of manual work with local storage. But it's probably worth throwing in some context as to what we are doing at Headstart / what we are thinking in case it flips some switches for others.

We are looking to add a fair bit of offline capability to our applications in November, December time so we haven't yet tackled the crux of the issue.

In the meantime we're probably going to be using something like redux-persist for some of our offline capability we need for an mvp.

https://github.com/rt2zz/redux-persist

I suppose what I'm thinking is that is there a reason feathers needs to support a mobile local adaptor itself?

As alluded to by @ekryski a set of reusable hooks in a library might be a better idea. Trying to support lots of adapters for mobile as well as server side might be a bit too much of a scope for feathers to support given (even above) the number of different solutions people would be using and asking for?

I for one would much prefer a library of hooks showing how to 'consolidate' based on mobile connectivity which each person can then apply to whatever local storage system they want to use.

Hope that makes sense and I haven't completely misunderstood.

@gor181 for reference.

@Mentioum how is your Nov/Dec MVP going, what did you decide to use?

I chose to use ForerunnerDB

On Sun, Nov 27, 2016, 12:12 PM Luke Browell notifications@github.com
wrote:

@Mentioum https://github.com/Mentioum how is your Nov/Dec MVP going,
what did you decide to use?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/feathersjs/feathers/issues/264#issuecomment-263144379,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACFSMbrn_nO1oyNsoK0F41BqaetzowkNks5rCeQqgaJpZM4HxjN7
.

>

Maximilian Alexander
[email protected]
www.maxofeden.com

@eddyystop is doing some great work on the offline front. You can find the guides with links to all related repositories at https://docs.feathersjs.com/guides/offline-first/readme.html

Specific discussions and questions should be directed to the appropriate repositories so I think we can close this.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NetOperatorWibby picture NetOperatorWibby  ·  4Comments

arve0 picture arve0  ·  4Comments

huytran0605 picture huytran0605  ·  3Comments

corymsmith picture corymsmith  ·  4Comments

jordanbtucker picture jordanbtucker  ·  4Comments