Operator behavior reference
159 registered expression operators, documented from 6,495 executed cases.
Read the coverage and testing methodology.
Each page separates SrotaX behavior from an optional MongoDB comparison section. The input tables are concrete regression cases, not a claim that every possible combination has been tested.
| Operator | Purpose | Cases |
|---|---|---|
| $abs | Returns absolute magnitude. | 22 |
| $acos | Computes inverse cosine. | 22 |
| $acosh | Computes inverse hyperbolic cosine. | 22 |
| $add | Adds numbers, or adds millisecond offsets to a single date. | 43 |
| $allElementsTrue | Tests whether every array value is truthy under Fluxion coercion. | 22 |
| $and | Requires all expression results to be truthy. | 41 |
| $anyElementTrue | Tests whether any array value is truthy under Fluxion coercion. | 22 |
| $arrayElemAt | Reads an array item at a positive or negative index. | 42 |
| $arrayToObject | Converts key/value entries into an object. | 22 |
| $asin | Computes inverse sine. | 22 |
| $asinh | Computes inverse hyperbolic sine. | 22 |
| $atan | Computes inverse tangent. | 22 |
| $atan2 | Computes two-argument inverse tangent. | 41 |
| $atanh | Computes inverse hyperbolic tangent. | 22 |
| $avg | Averages numeric values from one array expression or explicit operands; ignores nonnumeric values. | 60 |
| $binarySize | Counts bytes in text or supported binary values. | 22 |
| $bitAnd | Computes bitwise AND of integers. | 41 |
| $bitNot | Flips int32 or int64 bits, preserving integer width. | 37 |
| $bitOr | Computes bitwise OR of integers. | 41 |
| $bitXor | Computes bitwise exclusive OR of integers. | 41 |
| $bsonSize | Returns the actual BSON-encoded document size in bytes, or null for null input. | 22 |
| $ceil | Rounds upward to a whole number. | 22 |
| $cmp | Returns the ordering of two values. | 41 |
| $coalesce | Returns the first non-null expression. | 41 |
| $concat | Concatenates strings, skipping null operands. | 41 |
| $concatArrays | Concatenates arrays. | 41 |
| $cond | Evaluates Mongo truthiness and lazily returns the selected branch. | 61 |
| $convert | Converts input to a named target type with optional fallbacks. | 123 |
| $cos | Computes cosine. | 22 |
| $cosh | Computes hyperbolic cosine. | 22 |
| $dateAdd | Adds a calendar amount and returns a date value. | 83 |
| $dateDiff | Counts elapsed whole units between dates. | 103 |
| $dateFromParts | Builds a date value from calendar parts. | 223 |
| $dateFromString | Parses a date string and returns a date value. | 103 |
| $dateSubtract | Subtracts a calendar amount and returns a date value. | 83 |
| $dateToParts | Extracts calendar fields into an object. | 63 |
| $dateToString | Formats a typed date using Mongo 6 numeric format tokens. | 83 |
| $dateTrunc | Truncates a date and returns a date value. | 103 |
| $dayOfMonth | Extracts day of month using the host calendar. | 22 |
| $dayOfWeek | Extracts day of week using the host calendar. | 22 |
| $dayOfYear | Extracts day of year using the host calendar. | 22 |
| $degreesToRadians | Computes conversion from degrees to radians. | 22 |
| $divide | Divides the first numeric operand by the second. | 42 |
| $endsWith | Checks a literal text suffix. | 41 |
| $eq | Tests equality using BSON-aware comparison. | 41 |
| $exp | Raises e to the supplied exponent. | 22 |
| $expr | Evaluates an expression as a Fluxion passthrough extension. | 22 |
| $filter | Keeps array elements satisfying a boolean condition. | 64 |
| $first | Reads the first array element. | 22 |
| $firstN | Returns a new array without changing the source list. | 43 |
| $floor | Rounds downward to a whole number. | 22 |
| $function | Executes a JavaScript function in a restricted GraalJS context. | 61 |
| $getField | Reads a named field from an explicit object. | 44 |
| $gt | Tests whether the first value is greater. | 41 |
| $gte | Tests whether the first value is greater or equal. | 41 |
| $hour | Extracts hour using the host calendar. | 22 |
| $ifNull | Uses a fallback when the first expression is null or missing. | 41 |
| $in | Tests membership in an array without flattening the searched value. | 41 |
| $indexOfArray | Finds an item using Java equality. | 41 |
| $indexOfBytes | Searches text using byte positions; bounds have known differences. | 41 |
| $indexOfCP | Searches text using Unicode code-point positions. | 41 |
| $isArray | Tests whether a value is an array. | 22 |
| $isNumber | Tests whether a value is numeric. | 22 |
| $isoDayOfWeek | Extracts iso day of week using the host calendar. | 22 |
| $isoWeek | Extracts iso week using the host calendar. | 22 |
| $isoWeekYear | Extracts iso week year using the host calendar. | 22 |
| $last | Reads the last array element. | 22 |
| $lastN | Returns a new array without changing the source list. | 43 |
| $let | Evaluates an expression with locally bound variables. | 44 |
| $literal | Returns a value without evaluating it. | 21 |
| $ln | Computes the natural logarithm. | 22 |
| $log | Computes a logarithm using the supplied base. | 41 |
| $log10 | Computes the base-ten logarithm. | 22 |
| $lt | Tests whether the first value is less. | 41 |
| $lte | Tests whether the first value is less or equal. | 41 |
| $ltrim | Trims configured characters from the start of text. | 43 |
| $map | Evaluates an expression for each array element. | 63 |
| $max | Returns the maximum non-null value from one array expression or explicit operands. | 60 |
| $maxN | Returns a new array without changing the source list. | 43 |
| $median | Computes single-document statistics, ignoring nonnumeric values. | 59 |
| $mergeObjects | Combines objects with later values replacing earlier fields. | 41 |
| $millisecond | Extracts millisecond using the host calendar. | 22 |
| $min | Returns the minimum non-null value from one array expression or explicit operands. | 60 |
| $minDistance | Computes minimum planar or spherical distance to supplied points. | 63 |
| $minN | Returns a new array without changing the source list. | 43 |
| $minute | Extracts minute using the host calendar. | 22 |
| $mod | Returns the numeric remainder. | 41 |
| $month | Extracts month using the host calendar. | 22 |
| $multiply | Multiplies numeric operands. | 41 |
| $ne | Tests inequality using BSON-aware comparison. | 41 |
| $nin | Negates array membership. | 41 |
| $nor | Negates a disjunction. | 41 |
| $not | Negates one expression result. | 22 |
| $objectToArray | Converts object fields to key/value entries. | 22 |
| $or | Requires at least one truthy expression result. | 41 |
| $percentile | Computes single-document statistics, ignoring nonnumeric values. | 86 |
| $pow | Raises the first number to the second power. | 41 |
| $radiansToDegrees | Computes conversion from radians to degrees. | 22 |
| $range | Generates numbers from an inclusive start to an exclusive end. | 41 |
| $reduce | Folds an array into an accumulated value. | 64 |
| $regexFind | Finds the first regex match and its UTF-16 index. | 63 |
| $regexFindAll | Finds regex matches and their UTF-16 indexes. | 63 |
| $regexMatch | Tests whether a Java regular expression matches text. | 64 |
| $replaceAll | Replaces all literal text occurrences. | 63 |
| $replaceOne | Replaces the first literal text occurrence. | 63 |
| $reverseArray | Reverses array elements. | 22 |
| $round | Rounds a number to the specified decimal place using ties-to-even rounding (HALF_EVEN); the place defaults to zero. | 24 |
| $rtrim | Trims configured characters from the end of text. | 43 |
| $second | Extracts second using the host calendar. | 22 |
| $setDifference | Returns values from the first set absent from the second. | 41 |
| $setEquals | Tests unordered set equality. | 41 |
| $setField | Sets a named field on an object copy. | 63 |
| $setIntersection | Returns common distinct array values; zero arguments return an empty array. | 47 |
| $setIsSubset | Tests whether the first set is contained in the second. | 41 |
| $setIsSuperset | Tests whether the first set contains the second. | 41 |
| $setUnion | Returns distinct combined array values. | 41 |
| $sin | Computes sine. | 22 |
| $sinh | Computes hyperbolic sine. | 22 |
| $size | Counts elements of an array. | 22 |
| $slice | Extracts an array segment; negative indexes are not Mongo-compatible. | 60 |
| $sortArray | Returns a new array without changing the source list. | 42 |
| $split | Splits text using a Java regular-expression delimiter. | 41 |
| $sqrt | Computes the square root. | 23 |
| $startsWith | Checks a literal text prefix. | 41 |
| $stdDevPop | Computes single-document statistics, ignoring nonnumeric values. | 81 |
| $stdDevSamp | Computes single-document statistics, ignoring nonnumeric values. | 81 |
| $strLenBytes | Counts UTF-8 bytes in a string. | 22 |
| $strLenCP | Counts Unicode code points in a string. | 22 |
| $strcasecmp | Compares lower-cased strings. | 41 |
| $substr | Extracts a substring using UTF-16 indexes. | 60 |
| $substrBytes | Extracts text from a UTF-8 byte range. | 60 |
| $substrCP | Extracts text using Unicode code-point indexes. | 60 |
| $subtract | Subtracts numbers, subtracts a millisecond offset from a date, or returns the millisecond difference between two dates. | 41 |
| $sum | Sums numeric values from one array expression or explicit operands; ignores nonnumeric values. | 60 |
| $switch | Selects the first branch with a true boolean condition. | 43 |
| $tan | Computes tangent. | 22 |
| $tanh | Computes hyperbolic tangent. | 22 |
| $toArray | Parses a strict JSON string into an array. | 41 |
| $toBool | Converts a value to bool. | 22 |
| $toDate | Converts a value to date. | 22 |
| $toDecimal | Converts a value to decimal. | 22 |
| $toDouble | Converts a value to double. | 22 |
| $toInt | Converts a value to int. | 22 |
| $toLong | Converts a value to long. | 22 |
| $toLower | Converts text to lower case. | 22 |
| $toObject | Parses a strict JSON string into an object. | 41 |
| $toObjectId | Converts a value to objectid. | 22 |
| $toString | Converts a value to a string. | 22 |
| $toUpper | Converts text to upper case. | 22 |
| $topN | Sort an array and return its first N items without changing the source. | 62 |
| $trim | Trims configured characters from both ends of text. | 43 |
| $trunc | Truncates a number to an optional decimal place. | 41 |
| $tsIncrement | Reads increment from a Fluxion timestamp map. | 22 |
| $tsSecond | Reads seconds from a Fluxion timestamp map. | 22 |
| $type | Returns the BSON-style type name of a value. | 22 |
| $unsetField | Removes a named field from an object copy. | 43 |
| $week | Extracts week using the host calendar. | 22 |
| $year | Extracts year using the host calendar. | 22 |
| $zip | Combines corresponding elements of input arrays. | 42 |