MongoDB has a $min
operator that allows you to update the value of a field only if the specified value is less than the current value of the field.
In other words, if the $min
value is less than the current value in the document, the $min
value is used. Otherwise, the document’s value remains unchanged.