Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

5.1. E-commerce queries

This section continues our exploration of the e-commerce data model sketched out in the previous chapter. We’ve defined a document structure for products, categories, users, orders, and product reviews. Now, with that structure in mind, we’ll look at how you might query these entities in a typical e-commerce application. Some of these queries are simple. For instance, _id lookups shouldn’t be a mystery at this point. But we’ll also examine a few more sophisticated patterns, including querying for and displaying a category hierarchy, as well as providing filtered views of product listings. In addition, we’ll keep efficiency in mind by looking at possible indexes for some of these queries.

5.1.1. Products, categories, and reviews

Most e-commerce applications provide at least two basic views of products and categories. First is the product home page, which highlights a given product, displays reviews, and gives some sense of the product’s categories. Second is the product listing page, which allows users to browse the category hierarchy and view thumbnails of all the products within a selected category. Let’s begin with the product home page, in many ways the simpler of the two.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint