Search…
Operators

Operators

Operator expressions are similar to functions that take arguments.
Variable
Access via $
Brief Description
abs
$abs
returns the absolute value of a number
acos
$acos
returns a numeric value between 0 and π radians for x between -1 and 1
acosh
$acosh
returns the inverse hyperbolic cosine of a number
acl
$acl
N/A
add
$add
Adds two or more array properties or expressions. In addition to numbers, a single Date value may be included in the array
and
$and
Evaluates to true if all conditions in the passed in array evaluate to true
asin
$asin
returns the arcsine (in radians) of a number
asinh
$asinh
returns the hyperbolic arcsine of a number,
atan
$atan
returns the arctangent (in radians) of a number
atan2
$atan2
returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y),
atanh
$atanh
returns the hyperbolic arctangent of a number
ceil
$ceil
always rounds a number up to the next largest integer
convert
$convert
N/A
cos
$cos
returns the cosine of the specified angle, which must be specified in radians
dateFromParts
$dateFromParts
returns a date from the specified parts (year, month, and day values).
dateFromString
$dateFromString
Converts a date object to a string in a specified format, and expects an array of [, date_expression]
dateToParts
$dateToParts
Returns a document that contains the constituent parts of a given Date value as individual properties
DateToString
$DateToString
Converts a date object to a string according to a user-specified format
dayOfMonth
$dayOfMonth
Returns the day of the month for a date as a number between 1 and 31.
dayOfWeek
$dayOfWeek
Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).
dayofYear
$dayofYear
Returns the day of the year for a date as a number between 1 and 366
degreestoRadians
$degreestoRadians
Converts an input value measured in degrees to radians
divide
$divide
Divides one number by another and returns the result
exp
$exp
Takes the e^n of a number
floor
$floor
Returns the largest integer less than or equal to the specified number
hour
$hour
Returns the hour portion of a date as a number between 0 and 23
isoDayOfWeek
$isoDayOfWeek
Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday)
isoWeek
$isoWeek
Returns the week number in ISO 8601 format, ranging from 1 to 53
isoWeekYear
$isoWeekYear
Returns the year number in ISO 8601 format
log
$log
Takes the log of the first number in the second number's base.
log10
$log10
Calculates the log base 10 of a number and returns the result as a double
ltrim
$ltrim
Removes whitespace characters, including null, or the specified characters from the beginning of a string
mergeObjects
$mergeObjects
Combines multiple documents into a single document
milliseconds
$milliseconds
Returns the millisecond portion of a date as an integer between 0 and 999
minute
$minute
Returns the minute portion of a date as a number between 0 and 59
month
$month
Returns the month of a date as a number between 1 and 12
multiply
$multiply
Multiply the value of a field by a number
omit
$omit
N/A
or
$or
The $or operator performs a logical OR operation on an array of two or more and selects the documents that satisfy at least one of the .
pick
$pick
N/A
radiansToDegrees
$radiansToDegrees
Converts an input value measured in radians to degrees.
regexFind
$regexFind
Provides regular expression (regex) pattern matching capability in aggregation expressions
regexFindAll
$regexFindAll
Provides regular expression (regex) pattern matching capability in aggregation expressions. The operator returns an array of documents that contains information on each match.
regexMatch
$regexMatch
Performs a regular expression (regex) pattern matching and returns
replaceAll
$replaceAll
Replaces all instances of a search string in an input string with a replacement string
replaceOne
$replaceOne
Replaces the first instance of a search string in an input string with a replacement string
rtrim
$rtrim
Removes whitespace characters, including null, or the specified characters from the end of a string
second
$second
Returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds
sin
$sin
Returns the sine of a value that is measured in radians
split
$split
Divides a string into an array of substrings based on a delimiter
sqrt
$sqrt
Calculates the square root of a positive number and returns the result as a double
stdDevPop
$stdDevPop
Calculates the population standard deviation of the input values
stdDevSamp
$stdDevSamp
Calculates the sample standard deviation of the input values.
strcasecmp
$strcasecmp
Performs case-insensitive comparison of two strings
strLenBytes
$strLenBytes
Returns the number of UTF-8 encoded bytes in the specified string
strLenCP
$strLenCP
Returns the number of UTF-8 code points in the specified string
substr
$substr
Returns the number of UTF-8 encoded bytes in the specified string.
substrBytes
$substrBytes
Returns the substring of a string
substrCP
$substrCP
Returns the substring of a string
tan
$tan
Returns the tangent of a value that is measured in radians
toDate
$toDate
type conversion, convert to date, date conversion, aggregation
toLower
$toLower
Converts a string to lowercase, returning the result
toUpper
$toUpper
Converts a string to uppercase, returning the result
trim
$trim
Removes whitespace characters, including null, or the specified characters from the beginning and end of a string
week
$week
Returns the week of the year for a date as a number between 0 and 53
year
$year
Returns the year portion of a date
Last modified 1mo ago
Copy link