June 2015
Intermediate to advanced
192 pages
4h 8m
English
You can query CouchDB for documents by their ID, but of course, most of the time, you'll want to issue more complex queries, such as matching a field in a record against a particular value. CouchDB lets you define views of your data that consist of an arbitrary key in a collection of objects and then the objects derived from the view. When you specify a view, you're specifying two JavaScript functions: a map function that maps keys to items in your collection, and then an optional reduce function that iterates over the keys and values to create a final collection. In this recipe, we'll use the map function of a view to create an index of records by a single field.
Here's how ...
Read now
Unlock full access