Aggregate Functions
-
COUNT(array)- Returns the number of elements inarray -
MIN(array)- Returns the lowest value inarray -
MAX(array)- Returns the highest value inarray -
FIRST(array)- Returns the first element inarray -
LAST(array)- Returns the last element inarray -
AVG(array)- Returns the average value of the numerical values inarray(ignores non-numerical values) -
SUM(array)- Returns the sum of the numerical values inarray(ignores non-numerical values) -
ANY(array)- Returnstrueifarrayhas any elements
DataType Functions
-
MINVALUE()- Returns the singleton instance ofMinValue -
MAXVALUE()- Returns the singleton instance ofMaxValue -
OBJECTID()- Returns a new instance ofObjectId -
GUID()- Returns a new instance ofGuid -
NOW()- Returns the current timestamp in local time -
NOW_UTC()- Returns the current timestamp in UTC -
TODAY()- Returns the current date at 00h00min00s -
INT32(value)- Returnsvalueconverted toInt32, ornullif not possible -
INT64(value)- Returnsvalueconverted toInt64, ornullif not possible -
DOUBLE(value, culture)- Returnsvalueconverted toDoubleaccording to the specified culture, ornullif not possible -
DECIMAL(value, culture)- Returnsvalueconverted toDecimalaccording to the specified culture, ornullif not possible -
STRING(value)- Returns the string representation ofvalue -
BINARY(value)- Returnsvalueconverted toBsonBinary, ornullif not possible -
OBJECTID(value)- Returnsvalueconverted toObjectId, ornullif not possible -
GUID(value)- Returnsvalueconverted toGuid, ornullif not possible -
BOOLEAN(value)- Returnsvalueconverted toBoolean, ornullif not possible -
DATETIME(value, culture)- Returnsvalueconverted toDateTimein local time according to the specified culture, ornullif not possible -
DATETIME_UTC(value, culture)- Returnsvalueconverted toDateTimein UTC according to the specified culture, ornullif not possible -
DATETIME(year, month, day)- Returns a newDateTimeat 00h00min00s in local time based on the providedyear,monthandday -
DATETIME_UTC(year, month, day)- Returns a newDateTimeat 00h00min00s in UTC based on the providedyear,monthandday -
IS_MINVALUE(value)- ReturnstrueifvalueisMinValue,falseotherwise -
IS_MAXVALUE(value)- ReturnstrueifvalueisMaxValue,falseotherwise -
IS_NULL(value)- Returnstrueifvalueisnull,falseotherwise -
IS_INT32(value)- ReturnstrueifvalueisInt32,falseotherwise -
IS_INT64(value)- ReturnstrueifvalueisInt64,falseotherwise -
IS_DOUBLE(value)- ReturnstrueifvalueisDouble,falseotherwise -
IS_DECIMAL(value)- ReturnstrueifvalueisDecimal,falseotherwise -
IS_NUMBER(value)- Returnstrueifvalueis of a numerical type,falseotherwise -
IS_STRING(value)- ReturnstrueifvalueisString,falseotherwise -
IS_DOCUMENT(value)- ReturnstrueifvalueisBsonDocument,falseotherwise -
IS_arrayAY(value)- ReturnstrueifvalueisBsonarrayay,falseotherwise -
IS_BINARY(value)- ReturnstrueifvalueisBsonBinary,falseotherwise -
IS_OBJECTID(value)- ReturnstrueifvalueisObjectId,falseotherwise -
IS_GUID(value)- ReturnstrueifvalueisGuid,falseotherwise -
IS_BOOLEAN(value)- ReturnstrueifvalueisBoolean,falseotherwise -
IS_DATETIME(value)- ReturnstrueifvalueisDateTime,falseotherwise
Date Functions
-
YEAR(value)- Returns the year ofvalue, ornullif it is not aDateTime -
MONTH(value)- Returns the month ofvalue, ornullif it is not aDateTime -
DAY(value)- Returns the day ofvalue, ornullif it is not aDateTime -
HOUR(value)- Returns the hour ofvalue, ornullif it is not aDateTime -
MINUTE(value)- Returns the minutes ofvalue, ornullif it is not aDateTime -
SECOND(value)- Returns the seconds ofvalue, ornullif it is not aDateTime -
DATEADD(dateInterval, amount, value)dateIntervalis one of the following:y|year,M|month,d|day,h|hour,m|minute,s|secondamountis the amount of units defined bydateIntervalto be added tovalue
-
DATEDIFF(dateInterval, start, end)
dateIntervalis one of the following:y|year,M|month,d|day,h|hour,m|minute,s|secondstartandendare dates- The function returns the difference between the dates in units defines by
dateInterval
-
TO_LOCAL(date) - Returns
dateconverted to local time, ornullif is not aDateTime -
TO_UTC(date) - Returns
dateconverted to UTC, ornullif is not aDateTime
Math Functions
-
ABS(value)- Returns the absolute value ofvalue, ornullif it is not a numerical value -
ROUND(value, digits)- Returnsvaluerounded todigitsof precision, ornullif it is not a numerical value -
POW(x, y)- Returnsxto the power ofy(always as aDouble), ornullif either of them is not a numerical value
String Functions
-
LOWER(value)- Returnsvaluein lower case, ornullif it is not aString -
UPPER(value)- Returnsvaluein upper case, ornullif it is not aString -
LTRIM(value)- Returns a new string with leading whitespaces removed, ornullif it is not aString -
RTRIM(value)- Returns a new string with trailing whitespaces removed, ornullif it is not aString -
TRIM(value)- Returns a new string with leading and trailing whitespaces removed, ornullif it is not aString -
INDEXOF(value, match)- Returns the zero-based index of the first occurrence ofmatchinvalue -
INDEXOF(value, match, startIndex)- Returns the zero-based index of the first occurrence ofmatchinvalue. The search starts instartIndex -
SUBSTRING(value, startIndex)- Returns the substring ofvaluefromstartIndexto the end -
SUBSTRING(value, startIndex, length)- Returns the substring ofvaluestarting fromstartIndexand with length specified bylength -
SUBSTRING(value, oldValue, newValue)- Returns a new string with occurrences ofoldValuereplaced bynewValue -
LPAD(value, totalWidth, paddingChar)- Returns a new string left-padded tototalWidthlength withpaddingChar -
RPAD(value, totalWidth, paddingChar)- Returns a new string right-padded tototalWidthlength withpaddingChar -
SPLIT(value, separator)- Returns an arrayay containing the substrings ofvaluesplit byseparator -
FORMAT(value, format)- Returns the string representation ofvaluewith the provided format -
JOIN(array)- Takes an array of string and returns those strings joined by, -
JOIN(array, separator)- Takes an array of string and returns those strings joined byseparator
Misc Functions
-
JSON(value)- Takes a string representation of a JSON and returns a parsedBsonValue -
EXTEND(source, extend)- Merges two documents into one, copying their attributes. -
CONCAT(array1, array2)- Returns a new array containt the concatenation ofarray1andarray2 -
KEYS(document)- Returns an array containing every key indocument -
OID_CREATIONTIME(objectId)- Returns the creation time ofobjectId -
IIF(predicate, ifTrue, ifFalse)- ReturnsifTrueifpredicateevaluates totrue,falseotherwise -
COALESCE(left, right)- Returnsleftif it is notnull,rightotherwise -
LENGTH(value)- Returns the lenght ofvalue(if value isString,Binary,ArrayorDocument) -
TOP(values, num)- Returns the firstnumelements fromvalues -
UNION(array1, array2)- Returns the set union betweenarray1andarray2 -
EXCEPT(array1, array2)- Returns the set difference betweenarray1andarray2 -
DISTINCT(array)- Returns the distinct elements fromarray -
RANDOM()- Returns a randomInt32 -
RANDOM(min, max)- Returns a randomInt32betweenminandmax