February 2015
Intermediate to advanced
170 pages
3h 39m
English
N1QL provides a means to succinctly query collections within a document. Recall that to examine nested collections in a map function, you used to run a for loop over the items in that collection. To achieve similar results in N1QL queries, you can filter a collection using the ANY operator.
For example, if we continue to use the address property of brewery documents, we can search for only those addresses that are not empty. In the following example, we're checking the length of each address string as our condition. Note that if a document contained two addresses, where one was valid and another was an empty string, the condition would still be satisfied:
SELECT address FROM beer-sample WHERE type = "brewery" AND ANY addr ...
Read now
Unlock full access