MongoDB Type Conversion Operators

MongoDB Type Conversion Operators are a set of special operators used to convert and manipulate data types in both aggregation and regular queries. This page summarizes the type conversion operators available in MongoDB.

  1. $convert

    $convert is an aggregation pipeline operator in MongoDB that converts one data type to another data type.
  2. $isNumber

    $isNumber is a logical operator in MongoDB used to determine whether a field is of a numeric type.
  3. $toBool

    $toBool is a built-in operator in MongoDB used to convert a specified value to a Boolean value (true or false).
  4. $toDate

    In MongoDB, the $toDate operator is used to convert a specified value to a date type.
  5. $toDecimal

    The $toDecimal operator in MongoDB is used to convert a given value to a decimal number.
  6. $toDouble

    $toDouble is an aggregation operator in MongoDB used to convert the value of an expression to a double-precision floating-point number.
  7. $toInt

    The MongoDB $toInt operator converts a value to an integer.
  8. $toLong

    The MongoDB $toLong operator is an operator used to convert a given value to a long data type.
  9. $toObjectId

    $toObjectId is a built-in operator in MongoDB used to convert a string to an ObjectId.
  10. $toString

    In MongoDB, the $toString operator is used to convert any type of data to a string type.