Couchbase Lite 2.0 is a powerful NoSQL embedded data store for iOS, Android and .Net Mobile Platforms. In an earlier tutorial, we explored the basics of Database and Document CRUD operations using Couchbase Lite within your iOS Swift app. In addition to the standard CRUD operations, Couchbase Lite 2.0 brings powerful Query API with SQL-like semantics and Full-Text-Search (FTS) capabilities to the edge. While the previous tutorial discussed the use of a single instance of Couchbase Lite embedded within your app, you can in fact, have multiple local instances of Couchbase Lite.

We will explore a few additional capabilities of Couchbase Lite 2.0 in a new tutorial that we introduce here.

Tutorial

The tutorial will walk you through a swift app that will

  • Demonstrate how you can bundle, load and use a prebuilt instance of Couchbase Lite 2.0. In the previous tutorial, we had a single instance of Couchbase Lite embedded within the app. In this tutorial, we will have two instances of Couchbase Lite. One instance holds data that is pre-loaded with the app and is common to all users of the app on the device and the second instance holds user-specific data.
    There are several reasons why you may want to bundle your app with a prebuilt database. This would be suited for data that does not change or change that often, so you can avoid the bandwidth and latency involved in fetching/syncing this data from a remote server. This also improves the overall user experience by reducing the start-up time.
  • Introduce you to the basics of the QueryBuilder interface . We will use a simple pattern matching query.

App Overview

We will be extending the “User Profile” app that we introduced in the Fundamentals Tutorial

This version of the app does the following –

    • Allows users to log in and create or update his/her user profile information
    • As part of the user profile, users can now specify a university that they can select from a list of possible options .

The list of matching univerisities is queried (using the new Query API) from a local prebuilt “University” Couchbase Lite Database that is bundled in the app.

The user profile information is persisted as a Document in the local Couchbase Lite Database. So subsquently, when the user logs out and logs back in again, the profile information is loaded from the Database.

user profile app overview

Next Steps

At the end of the tutorial, you should have an understanding of how to use a prebuilt Couchbase Lite database within your iOS app. You should also gain familiarity with the QueryBuilder API and how you use it to build and execute queries against your local database.
Stay tuned for future tutorials that will extend this app to incorporate more functionality of Couchbase Mobile.
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 priya.rajagopal@couchbase.com. The Couchbase Forums are another good place to reach out with questions.

 

Author

Posted by Priya 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