Menu

MongoDB Array Operators

MongoDB’s array aggregation operators test, access, filter, slice, reverse, and convert array values. Browse the available operators and examples below.

  1. $arrayElemAt

    The MongoDB $arrayElemAt operator can be used to retrieve elements at a specific position in an array.
  2. $arrayToObject

    The $arrayToObject operator is an aggregation pipeline operator in MongoDB that is used to convert an array into a key-value pair object.
  3. $concatArrays

    In MongoDB’s aggregation pipeline, the $concatArrays operator is used to merge two or more arrays into one array.
  4. $filter

    The MongoDB $filter operator filters elements from an array based on a specified condition and returns a new array containing all elements that meet the condition.
  5. $indexOfArray

    The MongoDB $indexOfArray is an array operator that searches for the first occurrence of a specified element in an array and returns its index.
  6. $isArray

    The MongoDB $isArray operator is used to determine if an expression is an array.
  7. $objectToArray

    The MongoDB $objectToArray operator transforms a document into an array containing key-value pairs of that document.
  8. $range

    $range is an operator in MongoDB’s aggregation pipeline used to generate a sequence of numbers.
  9. $reverseArray

    $reverseArray is an array operator in the MongoDB aggregation framework that reverses the order of elements in an array.
  10. $size

    In MongoDB, the $size operator can be used to get the number of elements in an array field.
  11. $slice

    The $slice operator is a projection operator in MongoDB used to select a specified number of elements from an array.