SQL++ for Mobile
Description - How to use SQL++ Query Strings to build effective queries with Couchbase Lite for Ionic
Related Content - Live Queries | Indexes
N1QL is Couchbase's implementation of the developing SQL++ standard. As such the terms N1QL and SQL++ are used interchangeably in all Couchbase documentation unless explicitly stated otherwise.
Introduction
Developers using Couchbase Lite for Ionic can provide SQL++ query strings using the SQL++ Query API. This API uses query statements of the form shown in Example 1. The structure and semantics of the query format are based on that of Couchbase Server's SQL++ query language — see SQL++ Reference Guide and SQL++ Data Model.
Running
Use Database.createQuery
to define a query through an SQL++ string. Then run the query using the Query.execute()
method.
Example 1. Running a SQL++ Query
const query = database.createQuery('SELECT META().id AS thisId FROM inventory.hotel WHERE city="Medway"');
const resultSet = await query.execute();
Query Format
The API uses query statements of the form shown in Example 2.
Example 2. Query Format
SELECT ____
FROM ____
JOIN ____
WHERE ____
GROUP BY ____
ORDER BY ____
LIMIT ____
OFFSET ____