With the release of Couchbase Mobile 1.5 and Couchbase Server 5.0,mobile ,web and desktop apps can seamlessly access documents in the same Couchbase Server bucket.

This implies that a document created on the server via the Couchbase SDK will be automatically replicated to the mobile clients through the Sync Gateway and vice versa.

Note:This is an updated repost of the original version of this post

Background

Prior to Couchbase Mobile 1.5, if you wanted to replicate changes made to the server via the Couchbase SDK over to the mobile clients, your options were to :

  • Enable Bucket Shadowing. (Note that Bucket shadowing is deprecated in Couchbase Mobile 1.4).
  • Have your web app route the documents through the Sync Gateway using the REST interface.

Now, new in Couchbase Mobile 1.5, the sync metadata is part of the document’s Extended Attributes or XAttrs and is no longer embedded within the document. Additionally, the Sync Gateway can be configured to automatically import documents added to the server via the SDK and associate it with the relevant sync metadata.

Enabling Unified Bucket Access

Enabling shared bucket access is simple. You will have to specify a couple of new configuration options in Sync Gateway Config file
enable_shared_bucket_access to true: This enables Sync Gateway to use XAttrs
import_docs to continuous: This causes the Sync Gateway to automatically import documents added via the SDK

Deployment Note: In a non-accel SG deployment, only a single SG node should have import_docs=continuous to avoid duplicate processing of documents

Accessing the Sync Metadata

You can query for the XAttr via the Sync Gateway’s _raw Admin REST API.

Currently, there is no way to query for the document sync metadata via the server’s N1QL interface

Demo

Here is a video recording of a demo that showcases the power of unified bucket access from web and mobile clients.-

Questions?

If you have other questions or feedback, please leave a comment below or feel free to reach out to me at Twitter @rajagp or email me priya.rajagopal@couchbase.com.  The Couchbase Forums are another good place to reach out with questions.

 

Author

Posted by Rajagopal, Senior Director, Product Management

Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.

Leave a reply