Sync Gateway and Accessing Couchbase Server Directly

124 views
Skip to first unread message

Runar Jordahl

unread,
Sep 3, 2014, 3:33:01 AM9/3/14
to mobile-c...@googlegroups.com

 An old post to this group indicates that when using Sync Gateway, the underlying Couchbase Server bucket cannot be accessed by other clients:

“(…) you should not directly access Couchbase to update/store docs if you're using [Sync Gateway]. Sync Gateway is the intermediary that manages all the changes metadata/state for incoming/outgoing docs, and bypassing it would likely make a mess of the sync state of the docs. Instead, you'd probably want to do any/all changes to docs via the CouchDB-esque REST API that Sync Gateway provides.”
https://groups.google.com/forum/#!msg/mobile-couchbase/QVSZqYkTe5I/uIzN1mk6coYJ

The way I read this is that Sync Gateway uses a Couchbase Server bucket as its private storage. If you use Sync Gateway you need to deal with a different API than the Couchbase Server API. Also, features of Couchbase Server (like indexing & map-reduce) are not supported, or work different. Basically you are now dealing with a different type of database, which happens to use Couchbase Server to store its data.

Am I correct in these assumptions?

Also, if I were to access the data on my Sync Gateway server using a C# .NET client, which library should I use? A “raw” “CouchDB-esque” REST API? I would presumably not be able to use the regular .NET client ( http://www.couchbase.com/communities/net/getting-started ), as this library only accesses Couchbase Server, not Sync Gateway. So I get a better development experience at the client, but at the server I cannot any longer use the strong libraries for connecting to Couchbase.

I wanted to use all features of Couchbase (replication, scalable storage, indexes) and have server processes access it directly. Then parts of the data should be replicated to clients using Sync Gateway. But I guess this is not possible.


Kind regards,
Runar

Jens Alfke

unread,
Sep 3, 2014, 11:51:54 AM9/3/14
to mobile-c...@googlegroups.com

On Sep 3, 2014, at 12:33 AM, Runar Jordahl <runar....@gmail.com> wrote:

The way I read this is that Sync Gateway uses a Couchbase Server bucket as its private storage. If you use Sync Gateway you need to deal with a different API than the Couchbase Server API. Also, features of Couchbase Server (like indexing & map-reduce) are not supported, or work different. Basically you are now dealing with a different type of database, which happens to use Couchbase Server to store its data.

Basically yes. This is inevitable because Couchbase Server (in its current form) doesn't support the type of metadata that's necessary to track document histories for replication. Modifying documents through the Couchbase Server API doesn't update that metadata, which messes up the Sync Gateway's tracking of histories.

So I get a better development experience at the client, but at the server I cannot any longer use the strong libraries for connecting to Couchbase.

There are a number of libraries for accessing CouchDB-compatible databases from .NET.

I wanted to use all features of Couchbase (replication, scalable storage, indexes) and have server processes access it directly. Then parts of the data should be replicated to clients using Sync Gateway.

You should consider using bucket shadowing.

—Jens
Reply all
Reply to author
Forward
0 new messages