We have worked on a number of mobile apps using Couchbase as the backend data store and using the Ionic Framework as our mobile development platform of choice. Couchbase is a great choice as it provides reliable sync out of the box, but there are a couple of gotcha's when it comes to using it in hybrid mobile apps.
What is couchbase?
Couchbase is a scalable, open-source NoSQL database.
The main components are -
- Couchbase server - the main backend data store
- Couchbase sync gateway - the conduit for mobile devices
- Couchbase lite - couchbase database that runs natively on mobile devices
Experience with it
We recently used Couchbase to develop a proof of concept app called Gig City. This is a hybrid mobile app built using the Ionic Framework and using Couchbase Lite as the local database on the mobile device. By using Couchbase Lite, data is automatically synchronized between the mobile device and the Couchbase Server via the Couchbase Sync Gateway.
This architecture saved us a lot of time as it allowed us to focus on the data model on the mobile device and less on developing a REST API. It also allowed our mobile app to be offline first i.e. the users can can view the data even when offline.
The Couchbase plugin for hybrid (Cordova) apps, Couchbase-Lite-PhoneGap-Plugin, is not as feature complete as its native counterparts. It also has some bugs such as not supporting query keys. It is also incompatible with iOS’s current webview (WKWebView), which means that the mobile app experience is not quite as smooth as it could be.
How we overcame it
The source code for the Cordova Couchbase plugin was pretty easy to understand, so we were able to modify some of the source code in order to fix bugs. Specifically, we managed to fix a major bug regarding the authentication of users and the aforementioned bug of not being able to query a view using query keys.
What people should know about it
Whilst the Couchbase plugin for Cordova does have some shortcomings, Couchbase Mobile and the Sync Gateway are very powerful. You can save a lot of time because it allows you to focus on data modelling and because of sync, app users don't need to press the refresh button - your app reacts to data in real-time.
On the backend, Couchbase has the N1QL query language which is an incredibly powerful tool for querying data.
We have been pretty busy completing GigCity and working on other apps, so we haven't managed to give full details of our updates here ... we will be updating this blog.
In the meantime, if you want a copy of our updates, just drop us a line; email@example.com