Aggregation Pipeline OperatorsThe aggregation pipeline operators construct expressions for use in the aggregation pipeline stages. The following are the list of Aggregation Pipeline Operators. Arithmetic Expression OperatorsIt is used to perform arithmetic operations on numbers. Some arithmetic expression also supports data arithmetic. $absThe abs operator returns the absolute value of a number. Syntax: Example: $addIt adds two or more numbers and a date. If one of the arguments is a date, then the date treats the other argument as milliseconds to add to the date. Syntax: Example: $ceilThe ceil operator returns the smallest integer that is greater than or equal to the specified number. Syntax: Example: $divideIt divides one or more numbers by another and returns the result. Syntax: Example: $expThe exp operator is used to raise Euler's number to the specified exponent and returns the result. Syntax: Example: $floorThe floor operator returns the greatest integer less than or equal to the specified number. Syntax: Example: $lnThe ln operator calculates the natural logarithm of a number and returns the result as a double. Syntax: Example: $logThe log operator calculates the log of a number for the specified base and returns the result as double. Syntax: Example: $log10The log10 operator calculates the log base 10 of a number and returns the result as a double. Syntax: Example: $modThe mod operator divides one number with another and returns the remainder. Syntax: Example: $multiplyThe multiply operator gives the product of two or more numbers. Syntax: Example: $powThe pow operator raises the number to the given exponent and returns the result. Syntax: Example: $roundThe round operator rounds a number to a whole integer or a specified decimal place. Syntax: Example: $sqrtThe sqrt operator returns the square root of a positive number as double. Syntax: Example: $subtractThe subtract operator subtracts two or more numbers to return the difference of the number. Syntax: Example: $truncThe trunc command deletes the data from the specified decimal place. Syntax: Example: Array Expression Operator$arrayElemAtIt returns the element at the specified array index. Syntax: Example: $arrayToObjectThe arrayToObject operator converts an array into a single document. Syntax: Example: $concatArraysThe concatArrays operator joins the array to return the concatenated array. Syntax: Example: $filterThe filter operator selects a subset of an array to return the result based on the specified condition. Syntax: Example: $inThe in operator returns a boolean indicating that the specified value is in the array or not. Syntax: Example: $indexOfArrayThe indexOfArray operator searches the array for the occurrence of a specified value and returns the array index of the first occurrence. Syntax: Example: $isArrayIt determines and returns a Boolean value if the operand is an Array. Syntax: Example: $mapThe map operator attaches value to each item in an array and returns an array with the applied result. Syntax: Example: $objectToArrayThis operator converts a document to an array. Syntax: Example: $rangeThe range operator returns an array whose elements are a generated sequence of numbers. Syntax: Example: $reduceThe reduce operator applies an expression to each element in an array and combines them into a single value. Syntax: Example: $reverseArrayIt returns an array with the element in reverse order. Syntax: Example: $sizeThe size operator counts and returns the total number of items in an array. Syntax: Example: $sliceThe slice operator results in a subset of an array. Syntax: Example: $zipThe zip operator transposes an array so that the first element of the output array would be an array containing the first element of the first input array. Syntax: Example: Next TopicMongoDB limit() |