Key Takeaways About $min Operator

  • The $min operator in MongoDB updates a field with a specified value if it is less than the current value.
  • It compares values of different data types according to the BSON comparison order.
  • min operator creates the field and sets its value to the specified value if the field does not exist.
  • The $min operator is used in methods like update(), updateOne(), etc., as per requirements.

MongoDB – $min operator

MongoDB $min or minimum operator is one of the field update operators. $min operator updates the field with the specified value if the specified value is less than the current value.

The $min operator will compare the values of different data types according to the BSON comparison order. This operator can also be used in embedded/nested documents using dot notation.

One can use this operator in methods like update(), updateOne(), etc. according to your requirements. If the given field does not exist, then this operator will create a field and set the value of that field.

Similar Reads

Syntax

{ $min: { field1: value1, field2: value2 ... } }...

MongoDB $min Operator Example

In the following examples, we are working with:...

Key Takeaways About $min Operator

The $min operator in MongoDB updates a field with a specified value if it is less than the current value. It compares values of different data types according to the BSON comparison order. min operator creates the field and sets its value to the specified value if the field does not exist. The $min operator is used in methods like update(), updateOne(), etc., as per requirements....

Contact Us