[SERVER-42664] Add function to mongo shell for converting BSONObj to Array Created: 07/Aug/19  Updated: 29/Oct/23  Resolved: 09/Aug/19

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 4.3.1

Type: New Feature Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Claire Childs (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Sprint: STM 2019-08-12, STM 2019-08-26
Participants:
Story Points: 2

 Description   

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.



 Comments   
Comment by Githook User [ 16/Aug/19 ]

Author:

{'username': 'chasinglogic', 'email': 'chasinglogic@gmail.com', 'name': 'Mathew Robinson'}

Message: SERVER-42664 Correct usage of ICECC_VERSION
Branch: master
https://github.com/mongodb/mongo/commit/166a5d78c1103a58dbd41d1e45aa6037ba4a3e42

Comment by Githook User [ 09/Aug/19 ]

Author:

{'name': 'cchilds1', 'username': 'cchilds1', 'email': 'cchilds1@binghamton.edu'}

Message: SERVER-42664 add bsonObjToArray to shell
Branch: master
https://github.com/mongodb/mongo/commit/adb75a05a64e7d3a4afd8ae0ded6c183dbf0449f

Generated at Thu Feb 08 05:01:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.