6. Updating with Aggregation Pipelines and Arrays
Overview
This chapter introduces you to two additional features of update operations in MongoDB. You will first learn how to perform some complex update operations using pipeline support. Using pipeline support, you will be able to write a multi-step update expression and also refer to the values of other fields. Next, the chapter covers the updating of array fields in documents, which involves adding elements to an array, updating or deleting all or specific elements, creating arrays as a set, and sorting array elements. You will practice pushing unique elements to an array and sorting its elements as part of the final activity. By the end of this chapter, you will be able to derive update expressions based on the values of other fields and manipulate array fields in the documents of a collection.