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$arrayElemAtoperator can be used to retrieve elements at a specific position in an array. -
$arrayToObject
The$arrayToObjectoperator 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$concatArraysoperator is used to merge two or more arrays into one array. -
$filter
The MongoDB$filteroperator 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$indexOfArrayis an array operator that searches for the first occurrence of a specified element in an array and returns its index. -
$isArray
The MongoDB$isArrayoperator is used to determine if an expression is an array. -
$objectToArray
The MongoDB$objectToArrayoperator transforms a document into an array containing key-value pairs of that document. -
$range
$rangeis an operator in MongoDB’s aggregation pipeline used to generate a sequence of numbers. -
$reverseArray
$reverseArrayis an array operator in the MongoDB aggregation framework that reverses the order of elements in an array. -
$size
In MongoDB, the$sizeoperator can be used to get the number of elements in an array field. -
$slice
The$sliceoperator is a projection operator in MongoDB used to select a specified number of elements from an array.