MongoDB Comparison Operators

MongoDB comparison operators are a set of special operators used to perform comparison operations, including equality, inequality, greater than, less than, greater than or equal to, and less than or equal to. They can be used for conditional filtering in both aggregate and normal queries. This page summarizes the comparison operators in MongoDB.

  1. $cmp

    $cmp is a comparison operator in MongoDB used to compare two values and return the result of the comparison.
  2. $eq

    The Mongodb $eq operator is used to match documents that are equal to a specified value.
  3. $exists

    $exists is a query operator in MongoDB that is used to determine whether a specified field exists in a document.
  4. $gt

    The MongoDB $gt operator is used to compare whether the value of a field is greater than a specified value.
  5. $gte

    The $gte operator in MongoDB is used to compare whether the value of a field is greater than or equal to a specified constant value.
  6. $in

    The $in operator is a query operator in MongoDB that matches multiple values during a query.
  7. $lt

    In MongoDB, the $lt operator is used to query documents where a field is less than a certain value.
  8. $lte

    The $lte operator can be used for fields of type number, date, and string.
  9. $ne

    In MongoDB, the $ne operator is used to query documents that are not equal to the specified value.
  10. $nin

    The $nin operator in MongoDB is used to find documents in the MongoDB database that do not match a specified condition.
  11. $type

    The MongoDB $type operator is used to return the data type of a document field.