Conversion Functions
Tip
Literal types in WHERE clauses using conversion functions are converted automatically e.g.:
NoQL will automatically convert the date value and result in the following:
Supported Conversion Functions
CONVERT
CONVERT(expr,to)
Converts the expression to the specified mongo type: double, string, bool, date, int, objectId, long, decimals.
Example CONVERT usage
IFNULL
IFNULL(expr,expr)
Return the value if the expression is null.
Example using select without FROM clause for object generation
TO_BOOL
TO_BOOL(expr)
Convert the expression to a boolean.
TO_DATE
TO_DATE(expr)
Convert the expression to a date.
TO_DECIMAL
TO_DECIMAL(expr)
Convert the expression to a decimal.
TO_DOUBLE
TO_DOUBLE(expr)
Convert the expression to a double.
TO_INT
TO_INT(expr)
Convert the expression to an integer.
TO_LONG
TO_LONG(expr)
Convert the expression to a long.
TO_STRING
TO_STRING(expr)
Convert the expression to a string.
TO_OBJECTID
TO_OBJECTID(expr)
Convert the expression to a mongodb id.
TYPEOF
TYPEOF(expr)
Returns the mongo type of the expression.
Casting
NoQL supports cast operations with the following type mappings:
| MySQL Type | Mongo Type |
|---|---|
| VARCHAR | string |
| DECIMAL | decimal |
| INT | int |
| DATETIME | date |
| TIME | date |
| FLOAT | number |
| CHAR | string |
| NCHAR | string |
| TEXT | string |