-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Couchbase Essentials
By :

N1QL queries are not limited to simple data types such as strings and numbers. With N1QL, you are able to operate on JSON objects and arrays as you could with map functions written in JavaScript.
As a simple example of a nested object, consider the brewery documents in the beer-sample bucket. These documents have geo data contained in a nested object with the geo
property:
{ "type": "brewery", "geo": { "lng": -72.1234, "lat": 34.1234 } }
The geo
object contains properties for longitude and latitude. If you want to write a query to find a brewery's geo information, you can use the standard dot (.
) notation, which is common with most modern object-oriented programming languages:
SELECT geo.lon, geo.lat FROM beer-sample WHERE type = "brewery"
Arrays are another common data structure in JSON documents. N1QL supports working with arrays in a few ways. The beer-sample
database doesn't have much when it comes to interesting array data, but the brewery documents do...
Change the font size
Change margin width
Change background colour