Finding data with views

Finding data with views

You can index and query JSON documents by using views . Views are functions written in JavaScript that can serve several purposes in your application. You can use them to:

  • Find all the documents in your database that you need for a particular process

  • Create a copy of data in a document and present it in a specific order

  • Create an index to efficiently find documents by a particular value or by a particular structure in the document

  • Represent relationships between documents

  • Perform calculations on data contained in documents. For example, if you use documents to represent users and user points in your application, you can use a view to find the ten users that have the top scores.

This chapter will describe how you can do the following using Couchbase SDKs and view functions:

  • Extract and order specific data,

  • Creating an index and use it to perform efficient document lookups,

  • Retrieve a range of entries, and

  • Perform a reduce function, which computes a value based on entry values.

For additional information about views, see Views and indexes.