In order to perform an update, the update document needs to use update operators. At a minimum, you need to use the $set update operator to assign the new value. The update operators are broken out into categories, as follows:
- Fields ($currentDate, $inc, $min, $max, $mul, $rename, $set, $setOnInsert, $unset)
- Array ($, $[], $[<identifier>], $addToSet, $pop, $pull, $push, $pullAll)
- Bitwise ($bit)
In addition, there are modifiers ($each, $position, $slice, $sort) that are used in conjunction with $push so that updates can affect all or a subset of an embedded array. Further, the $each modifier can be used with $addToSet to add multiple elements to an embedded array. A more detailed discussion of the array and modifier operators is presented in Chapter 10, Working with Complex Documents across Collections. In this section, we will only deal with the fields update operators.
Bitwise update operators let you perform AND, OR, and XOR operations, at the binary...