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.

 

Posted by Priya Rajagopal, Developer Advocate, Couchbase

Priya Rajagopal is a Mobile Developer Advocate for Couchbase, living in Ann Arbor, MI. She has been professionally developing software for over 18 years and was most recently the Director of Mobile Development at a startup. Although her current interests lie in mobile development, she has previously worked on a range of technologies including IPTV, Social TV, targeted advertising, network management , RESTful architectures and platform security. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV architectural specifications. She has spent a decade in software R&D and is a co-inventor on almost 2 dozen US patents.

Leave a reply