MongoDB Array Operators
MongoDB array operators are a set of special operators used to manipulate array fields in documents. They allow you to perform various operations on arrays, such as adding, removing, filtering, sorting, mapping, and more. This page provides a summary of array operators in MongoDB.
-
$arrayElemAt
The MongoDB$arrayElemAt
operator can be used to retrieve elements at a specific position in an array. -
$arrayToObject
The$arrayToObject
operator is an aggregation pipeline operator in MongoDB that is used to convert an array into a key-value pair object. -
$concatArrays
In MongoDB’s aggregation pipeline, the$concatArrays
operator is used to merge two or more arrays into one array. -
$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. -
$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. -
$isArray
The MongoDB$isArray
operator is used to determine if an expression is an array. -
$objectToArray
The MongoDB$objectToArray
operator transforms a document into an array containing key-value pairs of that document. -
$range
$range
is an operator in MongoDB’s aggregation pipeline used to generate a sequence of numbers. -
$reverseArray
$reverseArray
is an array operator in the MongoDB aggregation framework that reverses the order of elements in an array. -
$size
In MongoDB, the$size
operator can be used to get the number of elements in an array field. -
$slice
The$slice
operator is a projection operator in MongoDB used to select a specified number of elements from an array.