Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13185

Investigate changes in SERVER-30967: Add $binarySize expression

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.3.3
    • manual, Server
    • None

    Description

      Description

      Downstream Change Summary

      Adds a $binarySize expression.

      Description of Linked Ticket

      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> }
      

      This will parse like all other unary expressions, and accept the argument by itself or as an array with one element.

      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}
      

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Issue Links

          Activity

            People

              jeffrey.allen@mongodb.com Jeffrey Allen
              backlog-server-pm Backlog - Core Eng Program Management Team
              Jeffrey Allen Jeffrey Allen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                2 years, 30 weeks ago