February 2015
Intermediate to advanced
170 pages
3h 39m
English
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 ...
Read now
Unlock full access