DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. Couchbase Lite for Data Storage in Ionic App Using Cordova Plugin

Couchbase Lite for Data Storage in Ionic App Using Cordova Plugin

Cordova plugins allow web-based apps running in a Cordova webview to access native platform functionality through a Javascript interface.

Priya Rajagopal user avatar by
Priya Rajagopal
·
Nov. 11, 18 · Opinion
Like (3)
Save
Tweet
Share
8.31K Views

Join the DZone community and get the full member experience.

Join For Free

Couchbase Lite is an embedded NoSQL database for iOS, Android and .Net platforms. The framework's API supports native platform bindings for Android (Java), iOS (Swift, ObjC) and UWP/Xamarin (csharp). This implies that if you are building a Cordova app and you want to use Couchbase Lite as your embedded data persistence layer, you will have to find a way to access Couchbase Lite's native APIs from within your Cordova web application. You can accomplish that with Cordova Plugins. Cordova plugins allow web-based apps running in a Cordova webview to access native platform functionality through a Javascript interface.

Architecture

At a high level, the architecture of a Cordova application that uses Cordova Plugins to access native code libraries is pretty straightforward.

  • The UI layer or the web app layer is written using HTML/Javascript and is common across mobile platforms.
  • The WebView is used for rendering the web app
  • The web app uses plugins to access native functionality. The Couchbase Lite Cordova Plugin is written in native platform language and is responsible for interfacing with Couchbase Lite. The plugin exposes a JS API that is accessible to the web app.

Tutorial

We have put together two tutorials, one for Android and one for iOS. Each tutorial will walk you through the steps on how you can build a Cordova plugin that will interface with Couchbase Lite 2.x on specific platform. This Couchbase Lite plugin will allow Cordova applications to use Couchbase Lite for data persistence. In our sample app, we will use for building our the frontend web app layer.

We will be working with a very simple app called the "Hotel-Lister." This app allows users to Query for and to display a list of hotels.

The hotels are queried for from a local pre-built Couchbase Lite database and displayed in the Ionic web app.

So let's get started! If you are developing for iOS, you can get started with the iOS tutorial) and if you are developing for Android, follow the instructions in the Android tutorial).

Next Steps

After completing the tutorial, you should have a good idea of how to use Couchbase Lite as a local data store within your Cordova Application on iOS and Android. Check out our tutorials site for more sample apps.

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

Acknowledgments

I would like to thank James Nocentini for his contributions to the tutorials and development of the sample apps.

mobile app Apache Cordova Data (computing) Data storage Ionic (mobile app framework)

Published at DZone with permission of Priya Rajagopal, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Promises, Thenables, and Lazy-Evaluation: What, Why, How
  • Core Machine Learning Metrics
  • Public Cloud-to-Cloud Repatriation Trend
  • Project Hygiene

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: