Updates are also often performed to clean up data. As an example, you notice that for some customers, the buildingName, floor, and roomApartmentCondoNumber fields are set to null. This can cause problems when customer reports are generated, and the management wants you to replace the null values with an empty string instead.
Because you will be using the updateMany() command, the potential for a total database meltdown disaster is great! Accordingly, to be on the safe side, here are the actions you can perform:
- Back up the database (discussed in the next section).
- Run a find() command that tests the query filter, ensuring the correct documents are affected.
- Make a note of the first customer key on the list produced by the find() command.
- Build an updateOne() command using the tested filter.
- Use findOne() to confirm that the first customer document was changed correctly.
- Rerun the first find() command, appending count(), to get a count of the documents remaining to...