February 2015
Intermediate to advanced
170 pages
3h 39m
English
The real power of composite keys isn't the ability to search in multiple fields, but the ability to perform grouping with aggregation. To illustrate this point, we'll revisit the blog post document with a new property for published date:
{
"title": "Composite Keys with Couchbase Views ",
"body": "Composite keys are arrays...",
"publishedDate": "2014-09-17",
"type": "post"
}Let's imagine that we want to display both a list of posts by year and month and the count of posts by year and month. By writing a view that uses compound keys and grouping methods, we are able to achieve both. Starting with the map function, we'll emit the year and month as values in our composite (array) key:
function(doc, meta) { if (doc.type == "post" &&doc.publishedDate) ...Read now
Unlock full access