O'Reilly logo

Node.js, MongoDB, and AngularJS Web Development by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding Specific Sets of Documents

In Chapter 14, “Manipulating MongoDB Documents from Node.js,” you learned about the find() method of the Collection object. This method returns a Cursor object to the callback function, providing access to the documents. If no query is specified, then all documents are returned, which is rarely what you want. Instead, you typically need a subset of documents that match a certain set of criteria.

To limit the number of documents the find() method finds, you apply a query object that limits the documents that will be returned in the Cursor object.

The code in Listing 15.1 performs a bunch of different queries against the word collection data set described earlier in this chapter. You should already recognize ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required