Mongodb findAndModify each document

mongodb

Solution

JohnnyHK's comments are right. The only way to do this is to `find()` all the documents, update them individually, and resave them.

Problem

I have a collection that contains a number of documents each document contains an array and I want to remove the lowest value from this Array for each document. What would be the most efficient way to achieve this? Is findAndModify capable of performing this type of operation? Do I need to use forEach?

Original source