PouchDB-find is a new API and syntax that allows for a simpler way to query PouchDB. It is much more suited to ad-hoc querying and a fair amount easier to learn than PouchDB’s current way of querying documents via Map/Reduce. It is a MongoDB-inspired query language to query a PouchDB database. It works with PouchDB, Cloudant Query and CouchDB Mango (CouchDB 2.0 Release).

At the moment, PouchDB-find is still in beta. We are working hard on getting it out of beta and to a stable release (V1). Once that is achieved we will integrate it into PouchDB to replace Map/Reduce as the default way to find documents.

Understanding how PouchDB-find translates your query and actually finds the documents, will really help you to write great queries for it. This post will explain how PouchDB-find works, and will highlight some of the constraints of the library.

Since PouchDB-find is a JavaScript implementation of CouchDB Mango, and CouchDB Mango is the underlying implementation for CouchDB 2.0 and Cloudant, the explanation here applies to CouchDB 2.0 and Cloudant as well.

Creating a basic index

To begin using PouchDB-find, we first need to create an index with a list of fields we want to query against.

Let’s create a user document structure to use for the queries in this blogpost.