Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-42664

Add function to mongo shell for converting BSONObj to Array

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.1
    • Affects Version/s: None
    • Component/s: Shell
    • None
    • Fully Compatible
    • STM 2019-08-12, STM 2019-08-26
    • 2

      The purpose of this function is to make it possible to convert the object

      {"": 1, "": 2}
      

      for sort keys returned by compound sort specifications into the array

      [1, 2]
      

      which can be meaningfully interacted with via JavaScript. The duplicate empty string field names in the object form are otherwise hidden by the first one. It should be possible to use this function on Objects which have non-duplicate and non-empty field names as well. In those cases, it can be thought of as a function similar to Object.values() but one that actually works for BSONInfo instances.

      We can model this function off the bsonWoCompare() and bsonBinaryEqual() functions where the mongo shell will define a bsonObjToArray() global function that uses ObjectWrapper::toBSON() to convert/extract the argument as a BSONObj. It should then use ValueReader::fromBSONArray() to convert the BSONObj into a JavaScript Array.

            Assignee:
            claire.childs@mongodb.com Claire Childs (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: