From MongoDB 4.0, you can use the $toObjectId aggregation pipeline operator to convert a string to an ObjectId.
The string must be a hexadecimal string of length 24.
From MongoDB 4.0, you can use the $toObjectId aggregation pipeline operator to convert a string to an ObjectId.
The string must be a hexadecimal string of length 24.
In MongoDB, the $rtrim aggregation pipeline operator removes whitespace from the end of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all periods (.), exclamation marks (!), etc from the end of a string.
In MongoDB, the $ltrim aggregation pipeline operator removes whitespace from the beginning of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all hyphen characters (-) from the beginning of a string.
In MongoDB, the $trim aggregation pipeline operator removes whitespace from the beginning and end of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all hyphen characters (-) or periods (.) or all s characters, etc.
From MongoDB 4.0, you can use the $toLong aggregation pipeline operator to convert a value to a long.
From MongoDB 4.0, you can use the $toInt aggregation pipeline operator to convert a value to an integer.
From MongoDB 4.0, you can use the $toDouble aggregation pipeline operator to convert a value to a double.
From MongoDB 4.0, you can use the $toDecimal aggregation pipeline operator to convert a value to a decimal.
From MongoDB 4.0, you can use the $toBool aggregation pipeline operator to convert a value to a boolean.
From MongoDB 4.0, you can use the $toString aggregation pipeline operator to convert a value to a string.