Couchbase Lite v3.0 Provides Enhanced Offline Capabilities for Ionic Apps
Our recent integration with Couchbase Lite aims to provide offline storage capabilities with minimal effort.
Ionic developers want to build critical apps that work offline and are highly performant. Yet there’s a knowledge gap when it comes to syncing offline data with the cloud and advanced local data management.
Updates for Couchbase Lite v3.0 Integration
Earlier this year, we released an updated integration for Couchbase Lite v3.0. This brings support for N1QL (Nickel) to mobile. N1QL for Mobile is a Couchbase implementation of an emerging SQL-for-JSON query language spec called SQL++. The Couchbase Lite API has been enhanced to support N1QL formatted query strings.
In previous versions, developers would use QueryBuilder (QB), which is described as a “comprehensive fluent interface that allows users to construct queries with SQL-like semantics.” QB is far more robust to write and clunky. Nickel, on the other hand, is more cross-platform compatible and given its SQL-like syntax is very recognizable to developers.
Below is an example of the syntax differences between QueryBuilder and N1QL for Mobile:
let query = QueryBuilder .select(SelectResult.all()) .from(DataSource.database(database)) .where(Expression.property("type") .equalTo(Expression.string("account")) .and(Expression.property("owner").equalTo("Max") ) .orderBy(Ordering.property("accountSize").ascending())
N1QL for Mobile
let queryStr = ` SELECT * FROM _ WHERE type="account" AND owner="Max" ORDER BY accountSize ASC ` let query = database.createQuery(query: queryStr)
The biggest advantage Nickel brings developers is the ability to reuse queries across platforms. This drastically reduces development, testing, and maintenance costs. To ensure web developers have access to these advantages, Ionic’s Couchbase Lite integration has been updated to adopt these improvements. It provides access to the entirety of Couchbase Lite’s functionality, without the need for any native experience.
Want to dive in today? We’ve put together a tutorial that allows you to search and bookmark from a Couchbase Lite database.
Not ready to get started just yet? Watch our recent LinkedIn Live event with Couchbase and Ionic where we talk about solving the 5 biggest challenges in mobile app development.