Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It’s easy to provide stock examples for updating this or that attribute in a MongoDB document. But with a production data model and a real application, complications will arise, and the update for any given attribute might not be a simple one-liner. In the following sections, I’ll use the e-commerce data model you saw in the last two chapters to provide a representative sample of the kinds of updates you’d expect to make in a production e-commerce site. You may find certain updates intuitive and other not so much. But overall, you’ll develop a better appreciation for the schema developed in chapter 4 and an improved understanding of the features and limitations of MongoDB’s update language.
Here you’ll see a couple of examples of targeted updates in action, first looking at how you calculate average product ratings and then at the more complicated task of maintaining the category hierarchy.