List of Listings

 

Chapter 1. A database for the modern web

Listing 1.1. A document representing an entry on a social news site

Chapter 2. MongoDB through the JavaScript shell

Listing 2.1. Typical explain() output for an unindexed query

Listing 2.2. explain() output for an indexed query

Chapter 3. Writing programs using MongoDB

Listing 3.1. A class for fetching tweets and archiving them in MongoDB

Listing 3.2. A simple Sinatra application for displaying and searching the Tweet archive

Listing 3.3. HTML with embedded Ruby for rendering the Tweets

Chapter 4. Document-oriented data

Listing 4.1. A sample product document

Listing 4.2. A category document

Listing 4.3. An e-commerce order, with line items, pricing, and a shipping address

Listing 4.4. A user document, with addresses and payment methods

Listing 4.5. A document representing a product review

Listing 4.6. Simulating the logging of user actions to a capped collection

Chapter 5. Queries and aggregation

Listing 5.1. Using MongoDB’s group command

Listing 5.2. Results of the group command

Listing 5.3. Querying the map-reduce output collection

Chapter 7. Indexing and query optimization

Listing 7.1. Viewing query plans with explain(true)

Appendix D. MongoDB in PHP, Java, and C++

Listing D.1. Sample PHP driver usage