Sync from PouchDB to Couchbase

I have been looking to use some mechanisms to sync the documents between my browsers database and couchbase. As couchbase lite is for mobile devices not for browsers hence i moved to find PouchDB as an aternative to store offline documents on browsers and can use the sync functionality to sync between the PouchDB and Couchbase.

Researching through found that PouchDB can sync with CouchDB but found nothing for Couchbase as it uses streams in Sync gateway. Some workaround are like

PouchDB <–>CouchDB <–> Couchbase

But putting CouchDB is an extra footprint in my case where my master DB is Couchbase.

Do we have mechanism to sync between

PouchDB <–> Couchbase
or if not there is it coming in any upcoming updates.

Hi,

I believe we have no plan for a connection between pouchdb and sync gateway. But we do have a plan for a JS implementation of Couchbase Lite, which should run on the browser. It’s very much work in progress right now and I have no date to give you, but it’s coming.

Actually @jamiltz told me we were implementing CORS support on Sync Gateway side to allow such a thing. Documentation is not live yet but you can look at it here: https://github.com/couchbaselabs/couchbase-mobile-portal/commit/1fd3f3e5b592029cb9e39615d2b0bff0ad0a6dd0

This would require to use the master branch of Sync Gateway/

Wonderful. Thanks very much.

I was trying to access the above link but didn’t worked for me.

Here’s a pet project using PouchDB and Sync Gateway.

Check out the config file: https://github.com/jamiltz/GrowthHackersReader/blob/master/server/sync-gateway.json

So in your proj, you can just add the CORS setting with the domain you’re serving your web app from.

Please keep in mind this is experimental and you should use the nightly build of PouchDB and latest from master on Sync Gateway. Hope this helps, let us know how it works for you.

Hello,

I want to use offline sync mechanism with couchbase lite for web application in HTML5. could you please help here. As I didn’t any web sample application which talks about offline sync mechanism in html5.

Thank you!
Narottam goyal

Hey @narottam.in,

You might check this out:

Best,

Is Couchbase building its own JS implementation per the comment above? Or does it officially support PouchDB?

From Couchbase’s blog posts and its mention of PouchDB in the Sync Gateway docs, it appears to be supported, but there is no mention of PouchDB in the Couchbase Mobile section on Couchbase.com.

I’m reluctant to use Couchbase because of this because I do not need or want to build a native mobile app. The mobile web is catching up to native and will beat native for the vast majority of mobile use cases IMO. If Couchbase embraced the mobile web, I think it would help attract many developers to the platform IMHO.

Hey @cquillen,

PouchDB is a community driven project and, although compatible, is not supported by Couchbase. If you’d rather use something supported by Couchbase, there is the Apache Cordova plugin that supports various mobile web frameworks like PhoneGap and Ionic Framework.

You can also take a look at the community driven NativeScript plugin if you’d prefer a mobile web framework that is not Apache Cordova based:

Best,

Hi @nraboy,

Thanks for getting back to me. By mobile web app, I mean a pure, web-based application, not a hybrid app created with PhoneGap, Ionic, NativeScript, etc.

Does Couchbase have plans to support this?

Thanks,

Corey

Hey @cquillen,

As of right now I don’t believe there are any plans to create a pure JavaScript SDK. There is a Node.js SDK, but this is a server side SDK, not 100% browser based JavaScript (hence Node).

What is your use case?

Best,

Hi @nraboy,

I am building a Field Service Management application for small businesses. It has both desktop and mobile components. I want field technicians to be able to access the software super easily.

For example, an email from their manager with a link to login to the app. And I want that link to work on a desktop computer, Android device, iOS device, Windows Phone, BlackBerry, etc. Small businesses need simple, cross-platform solutions like this IMHO. And large enterprises could save a lot of money with them.

On modern mobile devices, I will give the user a chance to opt-in to offline access (via PouchDB or a Couchbase JS solution), but the offline/local database feature will be optional.

Is Couchbase a good fit for this?

Thanks!

1 Like

Hi, I think that I am looking for the same thing as @cquillen.
In my words, document-json-database and RESTful should be the combination for a 2-tier application.
I can’t figure it out how to serv the pure-js-web-application which connects to couchbase.
I wonder if this is not the path your taking with Couchbase.
I want to avoid any 3rd server or language at server side, and any duplication of code at client side, keeping it as simple as possible.

1 Like