Couchbase Lite 2.x 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 Xamarin apps.
In addition to the standard CRUD operations, Couchbase Lite brings powerful Query API with SQL-like semantics and Full-Text-Search (FTS) capabilities to the edge. The previous tutorial discussed the use of a single instance of Couchbase Lite embedded within your apps. In this one we show, you can, in fact, have multiple local instances of Couchbase Lite!
We will explore a few additional capabilities of Couchbase Lite in a new tutorial that we introduce here.
Couchbase Lite + Xamarin Tutorial
The tutorial will walk you through a Xamarin solution that will demonstrate how you can bundle, load and use a prebuilt instance of Couchbase Lite
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. 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. This allows you to 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.
The tutorial also introduces 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 universities 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 subsequently, when the user logs out and logs back in again, the profile information is loaded from the database.
Next Steps
At the end of the tutorial, you should have an understanding of how to use a prebuilt Couchbase Lite database within your Xamarin apps. You should also gain familiarity with the QueryBuilder
API and how 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. Reach out to me at Twitter @probablyrealrob or email me at robert.hedgpeth@couchbase.com. The Couchbase Forums are another good place to reach out with questions.