IceDevil
IceDevil

Reputation: 154

CouchBase sync_gateway + web application?

By using couchbase sync_gateway for mobile sync(android,ios) you can still use the database from custom server side app?

My application needs to run on both mobile and web. I have angularjs for browsers and nodejs/express for server side.

If I will update the database form browser->node->couchbase ... mobile clients will get db update?! I think this is with no revisions so?!

Upvotes: 3

Views: 1968

Answers (3)

Thiago F. Alencar
Thiago F. Alencar

Reputation: 440

Update: Nowadays probably the best way to go is with PouchDB for the web side. You can monitor changes with AngularJS and make responsive interfaces that will automatically react to your data changes in the browser.

Upvotes: 0

MrYellow
MrYellow

Reputation: 408

I've attempted to approach it from a similar direction in PHP.

Sync_gateway is based on CouchDB API but has some changes and missing features in it's architecture when compared to a normal Couchbase or CouchDB instance.

Sync/Admin REST API:

  • Attachments aren't supported: Sync_gateway runs in memory passing JSON documents to clients and isn't designed to store larger binary files.

  • Views aren't supported (except for a few special sync_gateway views): A sync_gateway pipes documents through channels to the authenticated users instance of Couchbase Lite. View design documents are passed also then ran on the client to analyse the documents they have locally. Structurally views otherwise have no ability to change their contents based on which user is authenticated, as they are pre-computed indexes.

  • Get/store docs, adding/removing users, channels, roles, DB compact, registering new databases as sync_gateway and a few other handy features are exposed.

So depending on your needs it is possible to connect a web-app to sync_gateway and retrieve documents, however "bucket shadowing" with separate ACL system for the web-app is likely the solution for most applications.

Alternatively you could compile Couchbase Lite for the server node and have the web-app connect to it, however this Couchbase Lite instance will only represent a single user and contain only their channel's documents.

PHP Client for Sync Gateway: https://github.com/mryellow/PHP-on-CouchSync/

Upvotes: 1

Jessica Liu
Jessica Liu

Reputation: 36

if you are using the Node.js smart client for Couchbase Server, you can still co-exist with Couchbase Lite mobile clients using a workflow we call "bucket shadowing". For more information on this, check out: https://github.com/couchbase/sync_gateway/wiki/Bucket-Shadowing

Alternatively, you could use a Node.js library that interfaces directly with the Sync Gateway instead. For example, cradle: https://github.com/flatiron/cradle

But, for most use cases, I would recommend the bucket shadowing method instead.

Upvotes: 1

Related Questions