Couchbase
Deep dive - Part 2
Contents
-
Data Synchronization
Data Sync
-
Critical for enabling offline-first mobile app
-
The two critical aspects enabling this is:
-
Ability to locally store data on the device so it is always available to the user, whether online or offline
-
Ability to sync data to the cloud so it is available to the users on other devices when online.
Data Sync
Query
-
The query service supports the querying of data ( N1QL query language)
The basic N1QL query :
SELECT - The fields of each document to return
FROM - The data bucket in which to look
WHERE -The conditions that the document must satisfy
Query
Query
Data in Couchbase Server is stored in the form of documents, not row/columns
String matching can be accomplished using LIKE operator in the WHERE clause.
Example : % - Matches zero/more characters
Query
Filter based on arrays nested inside the document.
Using ANY/EVERY - SATISFIES construct.
Example : Expression after ANY clause allows us to assign name to an element in the array that we searching through. SATIESFIES - to specify filter condition
Query
INDEX
Indexes are needed for N1QL to do its work,
At least one index define to make a bucket queryable
Create primary index
Syntax :
CREATE PRIMARY INDEX ON 'bucket-name'
Couchbase
By nur amirah
Couchbase
- 132