Writing MapReduce Views

      During the view creation process, the output structure, field order, content, and any summary or grouping information desired in the view is defined.

      The fundamentals of a view are straightforward. A view creates a perspective on the data stored in Couchbase buckets in a format that can be used to represent the data in a specific way, define and filter the information, and provide a basis for searching or querying the data in the database based on the content.

      Views achieve this by defining an output structure that translates the stored JSON object data into a JSON array or object across two components, the key and the value. This definition is performed through the specification of two separate functions written in JavaScript. The view definition is divided into two parts, a map function and a reduce function:

      • Map functions

      • Reduce functions