Release Notes for MongoDB 4.0 - Aggregation
-
New Type Conversion Operators
MongoDB 4.0 adds the following new aggregation operators for type conversion:
Operator Description $convert
Convert value to specified type. $toBool
Convert value to boolean. $toDate
Convert value to Date. $toDecimal
Convert value to Decimal128. $toDouble
Convert value to Double. $toInt
Convert value to integer. $toLong
Convert value to long. $toObjectId
Convert value to ObjectId. $toString
Convert value to string. New String Operators
MongoDB 4.0 adds the following new aggregation string operators:
Operator Description $ltrim
Removes whitespace or the specified characters from the beginning of a string. $rtrim
Removes whitespace or the specified characters from the end of a string. $trim
Removes whitespace or the specified characters from the beginning and end of a string. Additional Improvements
$bucket
The
$bucket
stage no longer requiresboundaries
document arguments to be wrapped in$literal
.$dateToString
The
$dateToString
aggregation operator has the following option changes:NOTE
Requires
featureCompatibilityVersion
(fCV) set to"4.0"
or greater.- A new option
onNull
specifies the value to return if thedate
is null or missing. - The option
format
is now optional.
$dateFromParts
If the value specified for fields other than
year
,isoYear
, andtimezone
is outside the valid range,$dateFromParts
carries or subtracts the difference from other date parts to calculate the date. For more information, see Value Range$dateFromString
The
$dateFromString
aggregation operator takes an optionalformat
field.$currentOp
The aggregation pipeline stage
$currentOp
supports the following new options:idleSessions
option to return information on inactive sessions which are holding locks as part of a transaction.localOps
option to report operations that are running locally on the currentmongos
instance, rather than reporting operations that are running on the shards.
- A new option