Couchbase Lite sync with Firebase Database

I’am currently building an app based on FIrebase SDK. But one of the limitations of Firebase Database is it only syncs the data after when the app is connected to the internet, not packaged when the app is built. Is it possible to use Couchbase Lite as my app local database then use the ReST API to sync data from the Firebase Database only when necessary?

2 Likes

Using both together sounds like it would be hard. You’d effectively have to write your own replicator that talks to FireBase’s REST API and updates a Couchbase Lite database. Or am I misunderstanding what you’re asking?

You actually got my question. If that would be the case, I know that this might off-topic, but is there other alternatives that can do this job? Perhaps I have to migrate my database to Couchbase.

I don’t actually know enough about FireBase. If it doesn’t allow you to populate your local database directly (instead of downloading it from servers), then it seems like you’re out of luck using it.

Of course, from our perspective we’d be happy for you to switch to Couchbase, but I know that’s a lot of work.

Well, then I have to wait for FireBase to enable a local database or come up with a magical solution to get my goal done. Perhaps I’ll give Couchbase a shot.

Thank you @jens for your responses. Saved me from a lot of “googling”.

To clarify. Firebase offers offline persistence and automatic syncing of data. So you can certainly write data to Firebase and when a connection re-establishes it will automatically sync.

Firebase offline persistance

1 Like

That’s not the same thing. @visdyn is asking if there’s a way to start with a pre-populated local data store, so the app doesn’t have to pull a lot of data from the network when it’s first launched.

AFAIK this can’t be done with FireBase because the local store is treated as a cache. If you wrote a bunch of initial data to it on first launch, it would be treated as new data and get pushed up to the server as soon as the app goes online.

1 Like

Understood, and of course your response is 100% on point.

My comment was more to, while not directly addressing the initial post, Firebase can handle offline persistence of data. So for example, an app can write data to Firebase in ‘offline mode’ and as soon as it connects that data would be sync’d to the server. Also, if the data is written offline, it could also be read offline, within the same application start, with no internet interaction.

However, if the data is pre-packaged, it must come from somewhere… so is it stored in the app? If it’s stored in the app then why also additionally write it to a local or remote database at all?

I think for this use case, Couchbase could handle the entire workload (storage and syncing), and adding another database would over-complicate the issue.

1 Like

Some developers preload their app with a copy of a CBL database that’s already synced with the server, since this is faster than running the sync protocol on an empty database when the app first launches. Of course the server will have changed since that snapshot was taken, but the replicator will compare the checkpoints and incrementally pull just the changed documents.

1 Like