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 ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.