-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Fully Compatible
-
Query 2019-12-02
-
(copied to CRM)
The query team has discussed and decided on the following syntax/semantics:
Name: $binarySize
Alternate Names: $binSize, $byteSize
This expression takes an expression that evaluates to a string or BinData and return the size of the value in bytes. It will error if the result evaluates to a type other than string, BinData, or null. Given nullish, returns null.
Syntax:
{ $binarySize: <Expression> }
Original Description
Implement an aggregation expression that return the length of BinData type value.
This would work much in the same way as SERVER-14670
Examples
Input
db.coll.insert({_id: 0, bin: new BinData(3, "OEJTfmD8twzaj/LPKLIVkA==")})
Pipeline
db.coll.aggregate([{ $project: { "BinLength": {$binLenBytes: "$bin"} } }])
Output
{_id: 0, BinLength: 16}
- related to
-
SERVER-33582 Add $bsonSize expression
- Closed